InstCombine: Optimize (1 << X) Pred CstP2 to X Pred Log2(CstP2)
authorDavid Majnemer <david.majnemer@gmail.com>
Fri, 28 Jun 2013 23:42:03 +0000 (23:42 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Fri, 28 Jun 2013 23:42:03 +0000 (23:42 +0000)
commitb41f4bbfbd233fae70962a6b4049de2c08da2657
tree105e52e7efc662d3a06b095749a256d18c2c06f3
parent99666cb8f98ba9d84a7516a9f0bbfce5fb9a7df2
InstCombine: Optimize (1 << X) Pred CstP2 to X Pred Log2(CstP2)

We may, after other optimizations, find ourselves with IR that looks
like:

  %shl = shl i32 1, %y
  %cmp = icmp ult i32 %shl, 32

Instead, we should just compare the shift count:

  %cmp = icmp ult i32 %y, 5

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