[PATCH] D28308: [SCEV] Model ashr(shl(x, n), m) as mul(x, 2^(n-m)) when n > m
Z. Zheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 9 11:49:49 PST 2017
zzheng added inline comments.
================
Comment at: lib/Analysis/ScalarEvolution.cpp:5367
+ if (Value *LV = dyn_cast<Value>(BO->LHS)) {
+ // Transform AShr i32 %x, C to sext(trunc(udiv(x, (1 << C)))).
+ APInt Div = APInt::getOneBitSet(BitWidth, CI->getZExtValue());
----------------
This is failing test/Analysis/ScalarEvolution/scev-expander-reuse-unroll.ll. See inlined comments of the test.
I'd like to do this in a separated patch.
================
Comment at: test/Analysis/ScalarEvolution/scev-expander-reuse-unroll.ll:6
; CHECK: select
+; CHECK: select {{.*}} i32 %shr
; CHECK-NOT: select
----------------
efriedma wrote:
> This is defeating the point of the test. I would guess SCEVExpander isn't realizing that sext(trunc(udiv))) is equivalent to an ashr?
"%shr = ashr i32 %add, 16" becomes computable and SCEVExpander hoists its InsertPt to outer loop, causing FindValueInExprValueMap() to return {nullptr, nullptr}.
SCEVExpander then expands it literally and creates another 'select' instruction, failing the test.
Repository:
rL LLVM
https://reviews.llvm.org/D28308
More information about the llvm-commits
mailing list