[PATCH] D103424: [IndVars] Don't forget value when inferring nowrap flags

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 31 12:55:58 PDT 2021


lebedev.ri added a comment.

Thank you for looking into it. This makes sense to me.
`strengthenRightShift()` does something similar, without forgetting from SCEV.

I do suspect this is not NFC, because `ScalarEvolution::getNoWrapFlagsFromUB()`,
called by `ScalarEvolution::createSCEV()`, would pick up the newly-proved flags,
but since we didn't forget the SCEV, it naturally won't.

The fix is to promote `SimplifyIndvar::strengthenOverflowingOperation()` into SCEV,
and call it in `ScalarEvolution::getNoWrapFlagsFromUB()` first.
(likely, changing it to return the deduced flags, not actually changing them).
I would expect that SCEV dump test would be able to demonstrate the change.

Would it make sense to deal with that first?



================
Comment at: llvm/lib/Transforms/Utils/SimplifyIndVar.cpp:775
     BO->setHasNoUnsignedWrap();
-    SE->forgetValue(BO);
     Changed = true;
----------------
Looks like this was added in rL231306 / D7981.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103424/new/

https://reviews.llvm.org/D103424



More information about the llvm-commits mailing list