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
Please adhere to the coding standards: http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return