[vectorIntrinsics+mask] RFR: 8272100: VectorAPI: modify existing implementation of masked neg and not operation.
Jatin Bhateja
jbhateja at openjdk.java.net
Mon Aug 9 11:37:44 UTC 2021
On Mon, 9 Aug 2021 07:07:34 GMT, Xiaohong Gong <xgong at openjdk.org> wrote:
>> src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template line 611:
>>
>>> 609: return lanewise(XOR, broadcast(-1), m);
>>> 610: } else if (op == NEG) {
>>> 611: return lanewise(NOT, m).lanewise(ADD, broadcast(1), m);
>>
>> Why not stick to the same pattern is the non-masked `lanewiseTemplate` method?
>> Suggestion:
>>
>> if (op == NOT) {
>> return broadcast(-1).lanewise(XOR, this, m);
>> } else if (op == NEG) {
>> return broadcast(0).lanewise(SUB, this, m);
>
> Seems the result is not equal to `this` vector for the non-active lanes (false lane for `m`)?
Yes, result will not be same since broadcasted zero vector is first operand. We need to select the lanes of 'this' vector when corresponding mask bit is false.
-------------
PR: https://git.openjdk.java.net/panama-vector/pull/108
More information about the panama-dev
mailing list