This is an archive of the discontinued LLVM Phabricator instance.

[CodeGenPrepare][RISCV] Correct the MathUsed flag for shouldFormOverflowOp
ClosedPublic

Authored by craig.topper on Mar 23 2023, 11:51 PM.

Details

Summary

For add, if we match the constant edge case the add isn't used by
the compare so we shouldn't check for 2 users.

For sub, the compare is not a user of the sub so the math is
used if the sub has any users.

This regresses RISC-V which I will work on other patches for.

Diff Detail

Event Timeline

craig.topper created this revision.Mar 23 2023, 11:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 11:51 PM
craig.topper requested review of this revision.Mar 23 2023, 11:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 11:51 PM
RKSimon added inline comments.Mar 24 2023, 2:27 AM
llvm/lib/CodeGen/CodeGenPrepare.cpp
1587–1591

Why can't you keep the existing !matchUAddWithOverflowConstantEdgeCases(Cmp, Add) early out code?

craig.topper added inline comments.Mar 24 2023, 9:25 AM
llvm/lib/CodeGen/CodeGenPrepare.cpp
1587–1591

I can. I think I misunderstood the control flow here. I’ll change it back

Restore old code structure.
Check 1 use instead of 2 for sub. That's safer in case of a dead sub instruction.

craig.topper edited the summary of this revision. (Show Details)Mar 24 2023, 10:52 AM
craig.topper edited the summary of this revision. (Show Details)
RKSimon accepted this revision.Mar 26 2023, 7:39 AM

LGTM

This revision is now accepted and ready to land.Mar 26 2023, 7:39 AM