[PATCH] D34598: ScalarEvolution: Add URem support

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 11:31:14 PDT 2017


efriedma added inline comments.


================
Comment at: lib/Analysis/ScalarEvolution.cpp:2962
+    // If constant is zero, the result of the urem is undefined.
+    if (!RHSC->getValue()->isZero()) {
+      // If constant is a power of two, fold into a zext(trunc(LHS)).
----------------
Redundant check: zero isn't a power of two.


================
Comment at: lib/Analysis/ScalarEvolution.cpp:2968
+        unsigned LZ = RHSC->getAPInt().countLeadingZeros();
+        unsigned TruncBW = FullBW - LZ - 1;
+        Type *TruncTy = IntegerType::get(getContext(), TruncBW);
----------------
There's a logBase2 helper on APInt.


================
Comment at: test/Analysis/ScalarEvolution/flattened-0.ll:4
+define void @foo([7 x i8]* %a) {
+; CHECK: @foo
+entry:
----------------
CHECK-LABEL


https://reviews.llvm.org/D34598





More information about the llvm-commits mailing list