[PATCH][X86] Optimize shifting of result of a vector-compare
Quentin Colombet
qcolombet at apple.com
Fri Feb 21 15:21:08 PST 2014
Hi Adam,
This LGTM with two minors comments:
+define <8 x i16> @foo(<8 x i16> %a, <8 x i16> %b) #0 {
+; CHECK: .short 32
- Add a check LABEL here.
- Remove the #0, it seems you do not have any related attribute (same for bar).
If you still do not have commit access, sent the updated patch, I’ll commit for you!
Thanks,
-Quentin
On Feb 21, 2014, at 3:12 PM, Adam Nemet <anemet at apple.com> wrote:
>
> On Feb 20, 2014, at 8:13 PM, Adam Nemet <anemet at apple.com> wrote:
>
>> 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.
>
> Even BuildVectors that return true in isConstant can have undef elements. In this case constant-folding returns NULL so my new assert triggers. Function bar in the test case is an example.
>
> In this new version, I bail if constant-folding failed, i.e. when the const vector has an undef element.
>
> Retested as before.
>
> Adam
>
> <redundant-psll-4.patch>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140221/fd0f49ca/attachment.html>
More information about the llvm-commits
mailing list