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)
commit59939acd2684708a1c617f9e42b2206956804bb6
tree1861266aaa9d1539694c41dd23e83643222b98f7
parenta801dd5799bd6f6641ce3a7ea48f32d274ef95a0
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!

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