[PATCH] [InstCombineCompares] Added shl optimization for the instruction - icmp eq/ne (shl Const2, A), Const1
Sean Silva
chisophugis at gmail.com
Fri Oct 17 16:28:27 PDT 2014
On Fri, Oct 17, 2014 at 3:00 AM, Ankur Garg <ankur29.garg at samsung.com>
wrote:
> Hi majnemer, dexonsmith, suyog,
>
> Hi,
> The following patch implements the optimization for the instructions of
> the type:
> icmp eq/ne (shl Const2, A), Const1
>
> Such instructions can be converted to:
> icmp eq/ne A, (TrailingZeros(Const1) - TrailingZeros(Const2))
>
What?
(1 << A) == 0b1100
is equivalent to
A == 2
?
Notice that the produced expression in the proposed optimization is
invariant under the following transformation of the constants: changing any
bit above the least significant 1. However, the recognized expression is
not invariant under that change.
-- Sean Silva
>
> This handles only the equality operators for now. Other operators need to
> be handled.
>
> This patch is related to the http://reviews.llvm.org/D4068. The D4068
> implements this optimization for ashr/lshr operators. The following patch
> implements the optimization for shl operator.
>
> Please help in reviewing it.
>
> Thanks.
> Ankur
>
> http://reviews.llvm.org/D5839
>
> Files:
> lib/Transforms/InstCombine/InstCombine.h
> lib/Transforms/InstCombine/InstCombineCompares.cpp
> test/Transforms/InstCombine/icmp.ll
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141017/7a6a3160/attachment.html>
More information about the llvm-commits
mailing list