RFR: 8020282: Generated code quality: redundant LEAs in the chained dereferences [v2]

Manuel Hässig mhaessig at openjdk.org
Wed Jun 4 11:18:21 UTC 2025


On Tue, 3 Jun 2025 17:41:57 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> Manuel Hässig has updated the pull request incrementally with three additional commits since the last revision:
>> 
>>  - Add comment to benchmark as to why we fix the heap size
>>  - Add missing null chec
>>  - Fix typos
>
> src/hotspot/cpu/x86/peephole_x86_64.cpp line 255:
> 
>> 253: // This peephole recognizes graphs of the shape as shown above, ensures that the result of the
>> 254: // decode is only used by the derived oop and removes that decode if this is the case. Futher,
>> 255: // multipe leaP*s can have the same decode as their base. This peephole will remove the decode
> 
> Typo `multipe`

Fixed in [fb728f9](https://github.com/openjdk/jdk/pull/25471/commits/fb728f925442729b111fbe2b2c3cd57e3ed659c0)

> src/hotspot/cpu/x86/peephole_x86_64.cpp line 267:
> 
>> 265: //           |   /              \
>> 266: //           leaP*          MachProj (leaf)
>> 267: // In this case where te common parent of the leaP* and the decode is one MemToRegSpill Copy
> 
> Typo: `te`

Fixed in [fb728f9](https://github.com/openjdk/jdk/pull/25471/commits/fb728f925442729b111fbe2b2c3cd57e3ed659c0)

> src/hotspot/cpu/x86/peephole_x86_64.cpp line 268:
> 
>> 266: //           leaP*          MachProj (leaf)
>> 267: // In this case where te common parent of the leaP* and the decode is one MemToRegSpill Copy
>> 268: // away, this peephole can als recognize the decode as redundant and also remove the spill copy
> 
> Typo: `als`

Fixed in [fb728f9](https://github.com/openjdk/jdk/pull/25471/commits/fb728f925442729b111fbe2b2c3cd57e3ed659c0)

> src/hotspot/cpu/x86/peephole_x86_64.cpp line 324:
> 
>> 322: 
>> 323:   // Ensure the MachProj is in the same block as the decode and the lea.
>> 324:   if (!block->contains(proj)) {
> 
> Should we check `proj == nullptr` ?

Indeed, we should. Thank you for pointing it out.

I fixed it in [bf75c0d](https://github.com/openjdk/jdk/pull/25471/commits/bf75c0da751def40149b5548fd0c89595318fc11).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25471#discussion_r2126340673
PR Review Comment: https://git.openjdk.org/jdk/pull/25471#discussion_r2126341088
PR Review Comment: https://git.openjdk.org/jdk/pull/25471#discussion_r2126341424
PR Review Comment: https://git.openjdk.org/jdk/pull/25471#discussion_r2126342950


More information about the hotspot-compiler-dev mailing list