InstCombine: Combine (X+cst) < 0 --> X < -cst
authorDavid Majnemer <david.majnemer@gmail.com>
Sat, 1 Nov 2014 09:09:51 +0000 (09:09 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sat, 1 Nov 2014 09:09:51 +0000 (09:09 +0000)
commitf74443e53a62e5a26d4db0d804ef9e3d8d6b2499
treed1af6feeb3aaa98768d19c22b9f5f5ce023cf7f3
parent666a51320e75d3a3fc1b38c0b683496b40f49c18
InstCombine: Combine (X+cst) < 0 --> X < -cst

This can happen pretty often in code that looks like:
int foo = bar - 1;
if (foo < 0)
  do stuff

In this case, bar < 1 is an equivalent condition.

This transform requires that the add instruction be annotated with nsw.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221045 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineCompares.cpp
test/Transforms/InstCombine/icmp.ll