[PATCH] D28308: [SCEV] Model ashr(shl(x, n), m) as mul(x, 2^(n-m)) when n > m
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 16 16:51:04 PST 2017
efriedma added inline comments.
================
Comment at: lib/Analysis/ScalarEvolution.cpp:5271
+ if (CI->isNullValue())
+ return LShOp0SCEV; // shift by zero --> noop
+
----------------
I think you meant to return `getSCEV(L)` here? Please add a testcase for `(ashr (shl x, 1) 0)`.
================
Comment at: lib/Analysis/ScalarEvolution.cpp:5304
+ const SCEV *MulSCEV = getSCEV(
+ ConstantInt::get(TruncTy, Mul.getZExtValue()));
+ return getSignExtendExpr(
----------------
64 might not be large enough, and getZExtValue() will assert if the value doesn't fit into a 64-bit integer. The right code is something like `APInt Mul = APInt::getOneBitSet(TruncToWidth, LShAmt - AShrAmt); const SCEV *MulSCEV = getConstant(Mul);`. Please add a testcase like `(ashr (shl i128 x, 100) 1)` to show this works correctly.
Repository:
rL LLVM
https://reviews.llvm.org/D28308
More information about the llvm-commits
mailing list