================
@@ -11579,6 +11579,16 @@ 
ScalarEvolution::getLoopInvariantPredicate(CmpPredicate Pred, const SCEV *LHS,
   if (!ArLHS || ArLHS->getLoop() != L)
     return std::nullopt;
 
+  // A samesign compare is poison when its operands have different signs.
+  // To prove that the comparison holds on the backedge, we may need to pick
+  // that poison as true.
+  // But proving that it is monotonic may need the same poison to be false.
+  // E.g. when the IV changes its sign and the comparison becomes false.
+  // Both facts must hold for the same picked values for poisons. So drop
+  // samesign.
+  // If the predicate without samesign is true, then the samesign predicate
+  // is either true or poison.
----------------
nikic wrote:

I'd suggest copying this more concise comment instead: 
https://github.com/llvm/llvm-project/blob/cecdd532c97bb2addcfa6c115ea83ed19274a504/llvm/lib/Analysis/ScalarEvolution.cpp#L11705-L11707

I found the talk about picking values for poison here unnecessarily confusing.

https://github.com/llvm/llvm-project/pull/236093
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to