InstCombine: Optimize icmp eq/ne (shl Const2, A), Const1
authorDavid Majnemer <david.majnemer@gmail.com>
Sun, 19 Oct 2014 08:23:08 +0000 (08:23 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sun, 19 Oct 2014 08:23:08 +0000 (08:23 +0000)
commit242aeb9d840180ab25ab6632d2ee1009998e8aa0
tree7c133866a3c84900eade2de47bf744313f941256
parent908d4514f689035f1d36e03110e2cbc375360421
InstCombine: Optimize icmp eq/ne (shl Const2, A), Const1

The following implements the optimization for sequences of the form:
icmp eq/ne (shl Const2, A), Const1

Such sequences can be transformed to:
icmp eq/ne A, (TrailingZeros(Const1) - TrailingZeros(Const2))

This handles only the equality operators for now. Other operators need
to be handled.

Patch by Ankur Garg!

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