indvars: Improve LFTR by eliminating truncation when comparing against a constant.
authorAndrew Trick <atrick@apple.com>
Thu, 11 Jul 2013 17:08:59 +0000 (17:08 +0000)
committerAndrew Trick <atrick@apple.com>
Thu, 11 Jul 2013 17:08:59 +0000 (17:08 +0000)
commit53b28f86236fc548143656929f39f38d9dc83e06
treed7317e129df2e3231363fdc512ddb8fe5cb691ed
parent53c86db25b5b4e163c68dc91c8ce1bc8180e6ff3
indvars: Improve LFTR by eliminating truncation when comparing against a constant.

Patch by Michele Scandale!

Adds a special handling of the case where, during the loop exit
condition rewriting, the exit value is a constant of bitwidth lower
than the type of the induction variable: instead of introducing a
trunc operation in order to match correctly the operand types, it
allows to convert the constant value to an equivalent constant,
depending on the initial value of the induction variable and the trip
count, in order have an equivalent comparison between the induction
variable and the new constant.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186107 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/IndVarSimplify.cpp
test/Transforms/IndVarSimplify/exitcnt-const-arstart-const-opt.ll [new file with mode: 0644]