This is an archive of the discontinued LLVM Phabricator instance.

[IRCE] Support non-strict range check's predicate
ClosedPublic

Authored by aleksandr.popov on Apr 13 2023, 6:50 AM.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2023, 6:50 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
aleksandr.popov requested review of this revision.Apr 13 2023, 6:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2023, 6:50 AM
mkazantsev added inline comments.Apr 17 2023, 12:28 AM
llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
278–279

This whole code looks like a mess. It's really hard to follow what exactly is it doing. I guess your change should be the same for UGE, but from this code structure it's really hard to follow on how it's gonna happen.

I propose the following NFC refactoring:

  • If RHS is loop-variant, swap LHS/RHS and swap predicate;
  • all checks are either IV >(=) const or IV <(=) RHS (maybe not const). The former are "lower/both checks and latter are "upper/both" checks.

After that, your change would be: when we have IV <= RHS, check that RHS + 1 doesn not overflow (signed or unsigned overflow - depending on what predicate is used), and if yes, add 1 to RHS.

This, at least, would be easier to understand.

287

Name L is almost exclusively used for loops, call this LHSS.

I propose the following NFC refactoring

Thanks, done: https://reviews.llvm.org/D148720

mkazantsev accepted this revision.Apr 21 2023, 3:45 AM
This revision is now accepted and ready to land.Apr 21 2023, 3:45 AM
This revision was landed with ongoing or failed builds.Apr 21 2023, 4:34 AM
This revision was automatically updated to reflect the committed changes.