]> granicus.if.org Git - llvm/commit
[IndVars] Canonicalize comparisons between non-negative values and indvars
authorMax Kazantsev <max.kazantsev@azul.com>
Wed, 5 Jul 2017 06:38:49 +0000 (06:38 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Wed, 5 Jul 2017 06:38:49 +0000 (06:38 +0000)
commitf9de76f98745e919b0705dacbbed5a6ee3d9cd6a
tree08dd840392f53ad92fd0f1477a28fcdfaf9f2b0e
parentf12af4508e9c0ecc02bed39089a0d2f29b23bd60
[IndVars] Canonicalize comparisons between non-negative values and indvars

-If there is a IndVar which is known to be non-negative, and there is a value which is also non-negative,
then signed and unsigned comparisons between them produce the same result. Both of those can be
seen in the same loop. To allow other optimizations to simplify them, we turn all instructions like

  %c = icmp slt i32 %iv, %b
to

  %c = icmp ult i32 %iv, %b

if both %iv and %b are known to be non-negative.

Differential Revision: https://reviews.llvm.org/D34979

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307126 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/SimplifyIndVar.cpp
test/Analysis/ScalarEvolution/guards.ll
test/Transforms/IndVarSimplify/canonicalize-cmp.ll [new file with mode: 0644]
test/Transforms/IndVarSimplify/eliminate-comparison.ll
test/Transforms/IndVarSimplify/widen-loop-comp.ll