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)
commit549f4f25103c70c7b796e56fe28324ca5ad904b6
treeb533cf71c1c01df9e51d1721ff1c8ae10743e34e
parentc758df4053767b19709a3345eb22f73f8894931b
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.

llvm-svn: 221045
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp.ll