[PATCH][X86] Optimize shifting of result of a vector-compare
Adam Nemet
anemet at apple.com
Thu Feb 20 20:13:57 PST 2014
On Feb 18, 2014, at 4:44 PM, Adam Nemet <anemet at apple.com> wrote:
> 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.
Quentin pointed out offline that a BuildVector is not necessarily constant. This new version adds some extra checks to guarantee that. Retested on x86_64-apple-darwin.
Adam
-------------- next part --------------
A non-text attachment was scrubbed...
Name: redundant-psll-3.patch
Type: application/octet-stream
Size: 2142 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140220/c8b12c8a/attachment.obj>
More information about the llvm-commits
mailing list