[PATCH] [InstCombineCompares] Added shl optimization for the instruction - icmp eq/ne (shl Const2, A), Const1

Ankur Garg ankur29.garg at samsung.com
Fri Oct 17 03:00:36 PDT 2014


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))

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5839.15067.patch
Type: text/x-patch
Size: 6371 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141017/ab2e3a48/attachment.bin>


More information about the llvm-commits mailing list