RFR: 8354348: Enable Extended EVEX to REX2/REX demotion for commutative operations with same dst and src2 [v2]
Srinivas Vamsi Parasa
sparasa at openjdk.org
Mon Sep 8 21:44:55 UTC 2025
On Fri, 5 Sep 2025 22:03:59 GMT, Sandhya Viswanathan <sviswanathan at openjdk.org> wrote:
>> Srinivas Vamsi Parasa has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:
>>
>> - nomenclature change
>> - Merge branch 'master' of https://git.openjdk.java.net/jdk into cdemotion
>> - remove trailing whitespaces
>> - remove unused instructions
>> - 8354348: Enable Extended EVEX to REX2/REX demotion for commutative operations with same dst and src2
>
> src/hotspot/cpu/x86/assembler_x86.cpp line 13125:
>
>> 13123: emit_arith(op1, op2, src1, src2, second_operand_demotable);
>> 13124: }
>> 13125:
>
> This could be written something like below:
>
> void Assembler::emit_eevex_prefix_or_demote_arith_ndd(Register dst, Register src1, Register src2, VexSimdPrefix pre, VexOpcode opc,
> InstructionAttr *attributes, int op1, int op2, bool no_flags, bool use_prefixq, bool is_commutative) {
> bool demotable = is_demotable(no_flags, dst->encoding(), src1->encoding());
> if (!demotable && is_commutative) {
> if (is_demotable(no_flags, dst->encoding(), src2->encoding())) {
> demotable = true;
> // swap src1 and src2
> Register tmp = src1;
> src1 = src2;
> src2 = tmp;
> }
> }
> (void)emit_eevex_prefix_or_demote_ndd(src1->encoding(), dst->encoding(), src2->encoding(), pre, opc, attributes, no_flags, use_prefixq);
> emit_arith(op1, op2, src1, src2);
> }
>
>
> Then we don't need extra argument in emit_arith() and emit_eevex_prefix_or_demote_ndd.
Please see the updated code with the suggestion incorporated.
> src/hotspot/cpu/x86/assembler_x86.hpp line 812:
>
>> 810: void emit_eevex_prefix_or_demote_arith_ndd(Register dst, Register src1, Register src2, VexSimdPrefix pre, VexOpcode opc,
>> 811: InstructionAttr *attributes, int op1, int op2, bool no_flags = false, bool use_prefixq = false, bool is_commutative = false);
>> 812:
>
> The attributes parameter could be replaced by int size and the attributes computed inside the emit_eevex_prefix_or_demote_arith_ndd. Also then no need to have use_prefixq as a separate parameter, (size == EVEX_64bit) implies use_prefixq.
Please see the updated code to pass size and attributes computed inside the `emit_eevex_prefix_or_demote_arith_ndd`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26997#discussion_r2331441375
PR Review Comment: https://git.openjdk.org/jdk/pull/26997#discussion_r2331440906
More information about the hotspot-compiler-dev
mailing list