[llvm-commits] PATCH: Make 'trunc i8 %x to i1' canonical rather than 'icmp ne i8 (and i8 %x, 1), 0'

Chandler Carruth chandlerc at gmail.com
Thu Mar 29 15:57:08 PDT 2012


Here is an updated patch.

This fixes InstCombine to still make the transform which seems the real
intent of this canonicalization -- folding the trunc to a single bit into
some other mask operation and testing with zero. This is especially
interesting when the pattern is something like (trunc (lshr X, 3) to i1).
Here we can replace the shift with a simple mask and compare to zero.

It also teaches InstCombine to canonicalize various forms of the old
pattern which actually generate worse code if they ever reach codegen into
a trunc to i1.

Thoughts?

I'm entirely convinced whether this is the correct approach, so I'd
appreciate thoughts of others. There are 3 or 4 test failures I'm mopping
up where we were expecting the and+icmp pair, but none of them seem
interesting or noteworthy. Just shorter. ;]

-Chandler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120329/c581592b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: canon-trunc-i1.diff
Type: application/octet-stream
Size: 5135 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120329/c581592b/attachment.obj>


More information about the llvm-commits mailing list