[IndVars] Have `cloneArithmeticIVUser` guess better
authorSanjoy Das <sanjoy@playingwithpointers.com>
Fri, 16 Oct 2015 01:00:47 +0000 (01:00 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Fri, 16 Oct 2015 01:00:47 +0000 (01:00 +0000)
commit457377c0d4f4f0e0ff6b836407ef3baafea20e94
treea457cc7079f562cf2cd75553a8a0577866f7d0f1
parent694c4191ad5f685ec0d9dc0798be6203757987ca
[IndVars] Have `cloneArithmeticIVUser` guess better

Summary:
`cloneArithmeticIVUser` currently trips over expression like `add %iv,
-1` when `%iv` is being zero extended -- it tries to construct the
widened use as `add %iv.zext, zext(-1)` and (correctly) fails to prove
equivalence to `zext(add %iv, -1)` (here the SCEV for `%iv` is
`{1,+,1}`).

This change teaches `IndVars` to try sign extending the non-IV operand
if that makes the newly constructed IV use equivalent to the widened
narrow IV use.

Reviewers: atrick, hfinkel, reames

Subscribers: sanjoy, llvm-commits

Differential Revision: http://reviews.llvm.org/D13717

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250483 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/IndVarSimplify.cpp
test/Transforms/IndVarSimplify/iv-widen.ll