[PATCH] Merge OR of ICMPs of single bit differences

David Majnemer david.majnemer at gmail.com
Fri Apr 12 15:31:39 PDT 2013


This patch reorders two transforms that collide with each other:

One performs: (X == 13 | X == 14) -> X-13 <u 2
The other: (A == C1 || A == C2) -> (A & ~(C1 ^ C2)) == C1

The problem is that there are certain values of C1 and C2 that trigger both
transforms but the first one blocks out the second, this generates
suboptimal code.

Reordering the transforms should be better in every case and allows us to
do interesting stuff like turn:
  %shr = lshr i32 %X, 4
  %and = and i32 %shr, 15
  %add = add i32 %and, -14
  %tobool = icmp ne i32 %add, 0

into:
  %and = and i32 %X, 240
  %tobool = icmp ne i32 %and, 224

-- 
David Majnemer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130412/ed6f326d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: combine_or_one_bit.diff
Type: application/octet-stream
Size: 3211 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130412/ed6f326d/attachment.obj>


More information about the llvm-commits mailing list