[PATCH] [InstCombineCompares] Added shl optimization for the instruction - icmp ugt/ult/uge/ule (shl Const2, A), Const1

Ankur Garg ankur29.garg at samsung.com
Wed Nov 5 02:29:06 PST 2014


Hi majnemer, suyog, dexonsmith,

Hi,
The following patch implements the optimization for the instructions of the type:
icmp ugt/ult/uge/ule (shl Const2, A), Const1

Such instructions can be converted to:
icmp (operator) A, (LeadingZeros(Const2) - LeadingZeros(Const1))

where (operator) is based on the initial operator and the actual values of the constants.

This handles the unsigned inequality operators. Equality operators are handled in patch D5839.
This patch is an extension of above patch where only equality operators are handled for similar instructions.

For Signed Inequality operators, such optimizations can't be made as with each left shift a signed number may keep changing the sign. So, such optimizations can't be performed. 

Please help in reviewing it.

Thanks.
Ankur

http://reviews.llvm.org/D6131

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: D6131.15803.patch
Type: text/x-patch
Size: 9030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141105/4772b5bd/attachment.bin>


More information about the llvm-commits mailing list