RFR: 8328865: [c2] No need to convert "(x+1)+y" into "(x+y)+1" when y is a CallNode [v2]
Dean Long
dlong at openjdk.org
Thu Mar 28 22:57:32 UTC 2024
On Wed, 27 Mar 2024 08:45:55 GMT, SUN Guoyun <duke at openjdk.org> wrote:
>> This patch prohibits the conversion from "(x+1)+y" into "(x+y)+1" when y is a CallNode to reduce unnecessary spillcode and ADDNode.
>>
>> Testing: tier1-3 in x86_64 and LoongArch64
>>
>> JMH in x86_64:
>> <pre>
>> before:
>> Benchmark Mode Cnt Score Error Units
>> CallNode.test thrpt 2 26397.733 ops/s
>>
>> after:
>> Benchmark Mode Cnt Score Error Units
>> CallNode.test thrpt 2 27839.337 ops/s
>> </pre>
>
> SUN Guoyun has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two commits:
>
> - 8328865: [c2] No need to convert "(x+1)+y" into "(x+y)+1" when y is a CallNode
> - 8328865: [c2] No need to convert "(x+1)+y" into "(x+y)+1" when y is a CallNode
The difference in generate code above seems very x86-specific, depending on differences between 2-operand ADD vs 3-operand LEA. It's not obvious to me why this change would necessarily generate better code, even in some cases. And the requirement should be leaning towards better or no worse code in all cases on all platforms.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/18482#issuecomment-2026274309
More information about the hotspot-compiler-dev
mailing list