Since now SCEV can handle 'urem', an 'urem' is a better canonical form than an 'srem' because it has well-defined behavior
This is a follow up of D34598
Paths
| Differential D38072
[SimplifyIndvar] Replace the srem used by IV if we can prove both of its operands are non-negative ClosedPublic Authored by etherzhhb on Sep 19 2017, 7:17 PM.
Details Summary Since now SCEV can handle 'urem', an 'urem' is a better canonical form than an 'srem' because it has well-defined behavior This is a follow up of D34598
Diff Detail
Event Timelinesanjoy added inline comments.
This revision now requires changes to proceed.Sep 19 2017, 8:55 PM Comment Actions This is looking close; only some nitpicky comments inline
This revision now requires changes to proceed.Sep 20 2017, 10:16 AM
Comment Actions LGTM with comments addressed.
This revision is now accepted and ready to land.Sep 23 2017, 2:39 PM
Closed by commit rL314125: [SimplifyIndvar] Replace the srem used by IV if we can prove both of its… (authored by ether). · Explain WhySep 25 2017, 10:41 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 115974 lib/Transforms/Utils/SimplifyIndVar.cpp
test/Transforms/IndVarSimplify/replace-srem-by-urem.ll
|
Instead of creating another function this way, I thin a cleaner design would be to create a couple of small functions for the "i % n --> i if i is in [0,n).", "i+1) % n --> (i+1)==n?0:(i+1) if i is in [0,n)." cases and this case, and call them from SimplifyIndvar::eliminateIVRemainder.