Re-enable "[IndVars] Canonicalize comparisons between non-negative values and indvars"
authorMax Kazantsev <max.kazantsev@azul.com>
Sat, 8 Jul 2017 17:17:30 +0000 (17:17 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Sat, 8 Jul 2017 17:17:30 +0000 (17:17 +0000)
commitb9edcbcb1dc9f87bfd31ec7f1e2c6a8baf66e8e8
treebe6558d79d74cdf88a0170aa100275229483d8ef
parent15689aeae972263d15e7d9c8f0eae0de1062af20
Re-enable "[IndVars] Canonicalize comparisons between non-negative values and indvars"

The patch was reverted due to a bug. The bug was that if the IV is the 2nd operand of the icmp
instruction, then the "Pred" variable gets swapped and differs from the instruction's predicate.
In this patch we use the original predicate to do the transformation.

Also added a test case that exercises this situation.

Differentian Revision: https://reviews.llvm.org/D35107

llvm-svn: 307477
llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
llvm/test/Analysis/ScalarEvolution/guards.ll
llvm/test/Transforms/IndVarSimplify/canonicalize-cmp.ll [new file with mode: 0644]
llvm/test/Transforms/IndVarSimplify/eliminate-comparison.ll
llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll