[llvm] [SCEV] Prove no-self-wrap from negative power of two step (PR #101416)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 1 12:30:26 PDT 2024


================
@@ -10857,7 +10861,11 @@ bool ScalarEvolution::isKnownToBeAPowerOfTwo(const SCEV *S, bool OrZero) {
   auto *Mul = dyn_cast<SCEVMulExpr>(S);
   if (!Mul)
     return false;
-  return all_of(Mul->operands(), NonRecursive) && (OrZero || isKnownNonZero(S));
+  return all_of(Mul->operands(), NonRecursive) &&
+         (OrZero || isKnownNonZero(S)) &&
+         (!OrNegative || llvm::count_if(Mul->operands(), [this](const SCEV *S) {
----------------
preames wrote:

You're right.  I was originally thinking of this as power-of-two XOR negative power-of-two, and then generalized slightly, but you're right, this condition is a remnant of the XOR model.  Will kill shortly. 

https://github.com/llvm/llvm-project/pull/101416


More information about the llvm-commits mailing list