RFR: 8263058: Optimize vector shift with zero shift count [v2]
Tobias Hartmann
thartmann at openjdk.java.net
Thu Mar 11 10:13:11 UTC 2021
On Thu, 11 Mar 2021 02:07:18 GMT, Eric Liu <github.com+10482586+theRealELiu at openjdk.org> wrote:
>> Like scalar shift, vector shift could do nothing when shift count is
>> zero.
>>
>> This patch implements the 'Identity' method for all kinds of vector
>> shift nodes to optimize out 'ShiftVCntNode 0', which is typically a
>> redundant 'mov' in final generated code like below:
>>
>> add x17, x12, x14
>> ldr q16, [x17, #16]
>> mov v16.16b, v16.16b
>> add x14, x13, x14
>> str q16, [x14, #16]
>>
>> With this patch, the code above could be optimized as below:
>>
>> add x17, x12, x14
>> ldr q16, [x17, #16]
>> add x14, x13, x14
>> str q16, [x14, #16]
>>
>> [TESTS]
>> compiler/vectorapi/TestVectorShiftImm.java, jdk/incubator/vector,
>> hotspot::tier1 passed without new failure.
>
> Eric Liu has updated the pull request incrementally with one additional commit since the last revision:
>
> fix build failure
>
> Change-Id: Id7d6f4bbb5d8dde8d1a6c5c9cd5052d64fd978a9
Otherwise, looks good to me.
src/hotspot/share/opto/vectornode.hpp line 524:
> 522: ShiftVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
> 523: virtual Node* Identity(PhaseGVN* phase);
> 524: virtual int Opcode() const = 0;
I don't think the `Opcode` declaration is needed.
src/hotspot/share/opto/vectornode.cpp line 1285:
> 1283: // Shift by ZERO does nothing
> 1284: if (is_vshift_cnt(in2)) {
> 1285: if (phase->find_int_type(in2->in(1)) == TypeInt::ZERO) {
The ifs can be merged.
-------------
Marked as reviewed by thartmann (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/2911
More information about the hotspot-compiler-dev
mailing list