[PATCH] D141823: [SCEV] More precise trip multiples

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 16 03:39:09 PST 2023


nikic added a comment.

Precommit tests please.



================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:6317
+    return TZ >= BitWidth ? APInt::getZero(BitWidth)
+                          : APInt(BitWidth, 1).shl(TZ);
   }
----------------
APInt::getOneBitSet


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:6323
+    const SCEVTruncateExpr *T = cast<SCEVTruncateExpr>(S);
+    return getMaxConstantMultiple(T->getOperand()).trunc(BitWidth);
   }
----------------
I don't think this is correct. `trunc(X nuw* C)` is not, in general, the same as `trunc(X) nuw* trunc(C)`.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:6372
+    // If there are no wrap guarantees, find the trailing bits, which is the
+    // miminum of its operands.
+    uint32_t TZ = getMinTrailingZeros(N->getOperand(0));
----------------
minimum


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141823



More information about the llvm-commits mailing list