[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:57:20 PST 2017
zzheng added a comment.
In https://reviews.llvm.org/D28308#665317, @sanjoy wrote:
> Did you consider doing this same thing in two more general steps (with separate tests for each case):
>
> - Lower `ashr X C` as `sext(trunc(udiv(X, 1 << C)))`, irrespective of what `X` is
This is failing test/Analysis/ScalarEvolution/scev-expander-reuse-unroll.ll.
"%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.
> - Add a separate rule that `(A mul (1 << C0)) udiv (1 << C1)` is `sext(trunc(A mul (1 << (C0 - C1))))` if `C0 > C1`
For my test case, Shl is already lowered to a mul expr before processing AShr.
AShr can be lowered to udiv(1<<C1) but it's not easy to look for the pattern "(A mul (1 << C0)) udiv (1 << C1)".
Repository:
rL LLVM
https://reviews.llvm.org/D28308
More information about the llvm-commits
mailing list