[PATCH][X86] Optimize shifting of result of a vector-compare

Adam Nemet anemet at apple.com
Tue Feb 18 16:44:47 PST 2014


This change is motivated by the benchmark in SingleSource/Benchmarks/Misc/lowercase.c.

             pcmpgtw %xmm3, %xmm2
             pand    %xmm7, %xmm2      // xmm7 is <1, 1, 1, 1, 1, 1, 1, 1>
             psllw   $5, %xmm2

PCMP* sets its result to all ones or zeros so we can AND with the shifted mask rather than masking and shifting separately.

The patch adds this transformation to the DAGCombiner:

   (shl (and (setcc:i8v16 ...) N01C) N1C) -> (and (setcc:i8v16 ...) N01C<<N1C)

This is a similar transformation that is already done for sign-extending the result of setcc for targets where boolean values are either zero or all-ones.

If the patch looks good, please apply.

Adam

-------------- next part --------------
A non-text attachment was scrubbed...
Name: redundant-psll-2.patch
Type: application/octet-stream
Size: 2046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140218/e294fe84/attachment.obj>


More information about the llvm-commits mailing list