This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel][Mips] Correct corner case in G_UADDE legalization.
ClosedPublic

Authored by craig.topper on Aug 14 2023, 6:30 PM.

Details

Summary

If carryin was 1, and RHS is 0xffffffff we were not giving a carry
out.

In that case Res would be equal to LHS, so Res <u LHS would be false.
But there should be a carry out since carryin+RHS wraps around to 0.

Diff Detail

Event Timeline

craig.topper created this revision.Aug 14 2023, 6:30 PM
craig.topper requested review of this revision.Aug 14 2023, 6:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2023, 6:30 PM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm added inline comments.Aug 15 2023, 11:11 AM
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
3448

Should probably use an and here, that's more canonical for booleans plus that seems to be what the DAG does

craig.topper added inline comments.Aug 15 2023, 11:55 AM
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
3448

Are you refering to the code in LegalizeDAG?

I based my implementation off what we get from ExpandIntRes for an ADD in SelectionDAG for RISC-V. That path creates a wide setcc ult that gets legalized to select like the one I used.

You can see this in uaddo.i64 test case in test/CodeGen/RISCV/xaluo.ll for RV32.

arsenm accepted this revision.Aug 17 2023, 1:26 PM
arsenm added inline comments.
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
3448

Yes, I think it's weird that we're inventing new bugs in code that could be more or less directly ported. In the starter case introducing select of i1 feels wrong

This revision is now accepted and ready to land.Aug 17 2023, 1:26 PM
This revision was landed with ongoing or failed builds.Aug 17 2023, 3:13 PM
This revision was automatically updated to reflect the committed changes.