RFR: 8373480: Optimize multiplication by constant multiplier using LEA instructions [v6]

Jatin Bhateja jbhateja at openjdk.org
Fri Jan 9 10:28:00 UTC 2026


On Thu, 8 Jan 2026 16:05:47 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> test/hotspot/jtreg/compiler/c2/TestConstantMultiplier.java line 89:
>> 
>>> 87:         ));
>>> 88:         var testTemplate1 = Template.make(() -> scope(
>>> 89:             IntStream.of(81, 73, 45, 41, 37, 27, 25, 21, 19, 13, 11).mapToObj(
>> 
>> Is there something special about these values? If yes: add a code comment :)
>> If no: could we add random values to the list to improve coverage and find edge cases?
>
> Ah, I see now that these are the values from your lookup table in the optimization.
> 
> I think it would still be good if you added random values, just for result verification.
> And only enable IR rules for the special values.

We also do some clever optimization for POT multiplier in MulI/MulLNode::Ideal routines which breaks multiplication into LShift/Add/Sub nodes and but its target agnostic.

Reason why I only selected these constants were because we are specifically handling these cases through optimum LEA based instruction sequence in the backend and Machine level IR annotation guarantees that required constant operand patten was indeed selected during matching.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28759#discussion_r2675631954


More information about the hotspot-compiler-dev mailing list