[PATCH] D34979: [IndVars] Canonicalize comparisons between non-negative values and indvars

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 4 05:54:55 PDT 2017


mkazantsev created this revision.

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.


https://reviews.llvm.org/D34979

Files:
  lib/Transforms/Utils/SimplifyIndVar.cpp
  test/Analysis/ScalarEvolution/guards.ll
  test/Transforms/IndVarSimplify/canonicalize-cmp.ll
  test/Transforms/IndVarSimplify/eliminate-comparison.ll
  test/Transforms/IndVarSimplify/widen-loop-comp.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34979.105158.patch
Type: text/x-patch
Size: 4566 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170704/b9031b42/attachment-0001.bin>


More information about the llvm-commits mailing list