[PATCH] D108043: [NFCI][IndVars] rewriteLoopExitValues(): nowadays SCEV should not change `GEP` base pointer

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 13 08:28:03 PDT 2021


lebedev.ri created this revision.
lebedev.ri added reviewers: efriedma, mkazantsev, reames, fhahn, nikic.
lebedev.ri added a project: LLVM.
Herald added subscribers: javed.absar, hiraditya.
lebedev.ri requested review of this revision.

Currently/previously, while SCEV guaranteed that it produces the same value,
the way it was produced may be illegal IR, so we have an ugly check that
the replacement is valid.

But now that the SCEV strictness wrt the pointer/integer types has been improved,
i believe this invariant is already upheld by the SCEV itself, natively.

I think we should add an assertion, wait for a week, and then, if all is good,
rip out all this checking.
Or we could just do the latter directly i guess.

This reverts commit rL127839 <https://reviews.llvm.org/rL127839>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108043

Files:
  llvm/lib/Transforms/Utils/LoopUtils.cpp


Index: llvm/lib/Transforms/Utils/LoopUtils.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -1351,6 +1351,9 @@
 
     // FIXME: isValidRewrite() is a hack. it should be an assert, eventually.
     Phi.ValidRewrite = isValidRewrite(SE, Phi.ExpansionPoint, Phi.Expansion);
+    assert(Phi.ValidRewrite &&
+           "Now that the SCEV is strict wrt pointer/integer types, this "
+           "invariant is expected to be uphold by SCEV itself.");
     if (!Phi.ValidRewrite) {
       DeadInsts.push_back(Phi.Expansion);
       continue;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108043.366292.patch
Type: text/x-patch
Size: 649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210813/0a18eb83/attachment.bin>


More information about the llvm-commits mailing list