RFR: 8349582: APX NDD code generation for OpenJDK [v3]

Srinivas Vamsi Parasa sparasa at openjdk.org
Wed Mar 12 17:58:06 UTC 2025


On Wed, 5 Mar 2025 18:21:00 GMT, Sandhya Viswanathan <sviswanathan at openjdk.org> wrote:

>> Srinivas Vamsi Parasa has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   remove epopcount, elzcnt, etzcnt
>
> src/hotspot/cpu/x86/x86_64.ad line 5796:
> 
>> 5794: %}
>> 5795: 
>> 5796: 
> 
> A nit pick, unnecessary extra blank lines :).

Please see the additional blank lines removed in the updated code.

> src/hotspot/cpu/x86/x86_64.ad line 6239:
> 
>> 6237: 
>> 6238: 
>> 6239: instruct cmovI_regUCF2_ne(cmpOpUCF2 cop, rFlagsRegUCF cr, rRegI dst, rRegI src) %{
> 
> The cmovI_regUCF2_ne, cmovl_regUCF2_eq, cmovP_regUCF2_ne, cmovP_regUCF2_eq, cmovL_regUCF2_ne, cmovL_regUCF2_eq instructs could also use the ecmovl() instructions.

Please see the added NDD versions for cmovI_regUCF2_ne, cmovl_regUCF2_eq, cmovP_regUCF2_ne, cmovP_regUCF2_eq, cmovL_regUCF2_ne, cmovL_regUCF2_eq.

> src/hotspot/cpu/x86/x86_64.ad line 6871:
> 
>> 6869:   predicate(UseAPX);
>> 6870:   match(Set dst (AddI src1 src2));
>> 6871:   effect(KILL cr);
> 
> We should also bring in the corresponding flag(PD::...); line from instruct addI_rReg in this and other rules where applicable.

Please see the updated code with flags(PD::...)

> src/hotspot/cpu/x86/x86_64.ad line 8253:
> 
>> 8251: %}
>> 8252: 
>> 8253: instruct negI_rReg_ndd(rRegI src, rRegI dst, immI_0 zero, rFlagsReg cr)
> 
> A nit pick in many of the new negI/negL instructs, we usually list the dst first in instruct.

Please see the order of dst and src fixed.

> src/hotspot/cpu/x86/x86_64.ad line 9060:
> 
>> 9058: 
>> 9059: // Arithmetic Shift Right by variable
>> 9060: instruct sarI_rReg_CL_ndd(rRegI dst, rRegI src, rcx_RegI shift, rFlagsReg cr)
> 
> The new instructs sarI_rReg_CL_ndd, shrI_rReg_CL_ndd, salL_rReg_CL_ndd, sarL_rReg_CL_ndd, shrL_rReg_CL_ndd  could be removed and the original !bmi2 versions could be kept. We dont need to optimize with APX instructions for non bmi2 platforms.

Please see the updated code which removed NDD support for non bmi2 platforms.

> src/hotspot/cpu/x86/x86_64.ad line 10401:
> 
>> 10399: %}
>> 10400: 
>> 10401: instruct orI_rReg_imm_rReg_ndd(rRegI dst, immI src1, rRegI src2, rFlagsReg cr)
> 
> It looks to me that we only need one of orI_rReg_rReg_imm_ndd or orI_rReg_imm_rReg_ndd as orI is a commutative operator.

After doing a quick test, it was noticed that both the rules (orI_rReg_rReg_imm and  orI_rReg_imm_rReg) are needed to generate NDD instruction depending on the position of the immediate value.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23501#discussion_r1992013267
PR Review Comment: https://git.openjdk.org/jdk/pull/23501#discussion_r1992014445
PR Review Comment: https://git.openjdk.org/jdk/pull/23501#discussion_r1992015478
PR Review Comment: https://git.openjdk.org/jdk/pull/23501#discussion_r1992016105
PR Review Comment: https://git.openjdk.org/jdk/pull/23501#discussion_r1992017266
PR Review Comment: https://git.openjdk.org/jdk/pull/23501#discussion_r1992021443


More information about the hotspot-compiler-dev mailing list