RFR: 8288294: [vector] Add Identity/Ideal transformations for vector logic operations

Xiaohong Gong xgong at openjdk.org
Thu Jun 30 02:57:38 UTC 2022


On Thu, 30 Jun 2022 02:30:31 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> This patch adds the following transformations for vector logic operations such as "`AndV, OrV, XorV`", incuding:
>> 
>>   (AndV v (Replicate m1))   => v
>>   (AndV v (Replicate zero)) => Replicate zero
>>   (AndV v v)                => v
>> 
>>   (OrV v (Replicate m1))    => Replicate m1
>>   (OrV v (Replicate zero))  => v
>>   (OrV v v)                 => v
>> 
>>   (XorV v v)                => Replicate zero
>> 
>> where "`m1`" is the integer constant -1, together with the same optimizations for vector mask operations like "`AndVMask, OrVMask, XorVMask`".
>
> src/hotspot/share/opto/vectornode.cpp line 1802:
> 
>> 1800:   // (AndV (Replicate zero) src)   => (Replicate zero)
>> 1801:   // (AndVMask (MaskAll zero) src) => (MaskAll zero)
>> 1802:   if (VectorNode::is_all_zeros_vector(in(1))) {
> 
> Why you expect it to be `in(1)` instead of `in(2)` as in previous case? Do we create inputs in such order based on mask value?
> At least add comment explaining it.

We also have the case that the all zeros vector is `in(2)` in the followed codes. Please see line 1817. The main reason to do the different handle is the consideration for the predicated vector operations in Vector API.

> src/hotspot/share/opto/vectornode.cpp line 1838:
> 
>> 1836:   // (OrV src (Replicate zero))   => src
>> 1837:   // (OrVMask src (MaskAll zero)) => src
>> 1838:   if (VectorNode::is_all_zeros_vector(in(2))) {
> 
> The same question as for `AndVNode`.

The same as `AndVNode`.

-------------

PR: https://git.openjdk.org/jdk/pull/9211


More information about the hotspot-compiler-dev mailing list