[PATCH] D87832: [IndVars] Remove monotonic checks with unknown exit count

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 03:26:12 PDT 2020


lebedev.ri added a comment.

This looks reasonable to me, but i'd prefer to defer to other reviewers.



================
Comment at: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:2396
+    return false;
+  // Value of IV on max possible last iteration.
+  const SCEV *Last = AR->evaluateAtIteration(MaxIter, *SE);
----------------
`// Value of IV on *suggested* max possible last iteration.`?


================
Comment at: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:2407-2412
+  if (Step == One)
+    NoOverflowPred =
+        CmpInst::isSigned(Pred) ? ICmpInst::ICMP_SLE : ICmpInst::ICMP_ULE;
+  else
+    NoOverflowPred =
+        CmpInst::isSigned(Pred) ? ICmpInst::ICMP_SGE : ICmpInst::ICMP_UGE;
----------------
This seems fragile, i'd suggest
```
ICmpInst::Predicate NoOverflowPred = CmpInst::isSigned(Pred) ? ICmpInst::ICMP_SLE : ICmpInst::ICMP_ULE;
if (Step == MinusOne)
  NoOverflowPred = CmpInst::getSwappedPredicate(NoOverflowPred);
```


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

https://reviews.llvm.org/D87832



More information about the llvm-commits mailing list