This patch transforms (and (srl X 30) 2) into (add Y Y), where
Y = (srl X 31). In x86 assembly:
c1 e8 1e shr $0x1e,%eax 83 e0 fe and $0xfffffffe,%eax
is transformed into:
c1 e8 1f shr $0x1f,%eax 01 c0 add %eax,%eax
When the source and destination operand are different, we can emit
lea:
c1 ef 1f shr $0x1f,%edi 8d 04 3f lea (%rdi,%rdi,1),%eax
eliminating the need for a mov instruction.
This patch fixes:
We might be able to get SimplifyDemandedBits to recognise this as shrl $30, %eax (with suitable TLI checks)