RFR: 8369435: C2: transform (LShiftX (SubX con0 a), con1) into (SubX con0<<con1 (LShiftX a con1))

Quan Anh Mai qamai at openjdk.org
Thu Oct 16 12:14:44 UTC 2025


On Thu, 16 Oct 2025 09:36:03 GMT, Roland Westrelin <roland at openjdk.org> wrote:

> We already transform:
> 
> (LShiftX (AddX a con0), con1) into (AddX (LShiftX a con1) con0<<con1)
> 
> THis is a variant with SubX. I found that this helps RCE.

LGTM

src/hotspot/share/opto/mulnode.cpp line 1096:

> 1094:     // Left input is a sub from a constant?
> 1095:     const TypeInteger* t11 = phase->type(add1->in(1))->isa_integer(bt);
> 1096:     if (t11 && t11->is_con()) {

`t11 != nullptr`

src/hotspot/share/opto/mulnode.cpp line 1098:

> 1096:     if (t11 && t11->is_con()) {
> 1097:       // Compute X << con0
> 1098:       Node *lsh = phase->transform(LShiftNode::make(add1->in(2), in(2), bt));

`Node* lsh`

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

Marked as reviewed by qamai (Committer).

PR Review: https://git.openjdk.org/jdk/pull/27842#pullrequestreview-3344504227
PR Review Comment: https://git.openjdk.org/jdk/pull/27842#discussion_r2435668987
PR Review Comment: https://git.openjdk.org/jdk/pull/27842#discussion_r2435668174


More information about the hotspot-compiler-dev mailing list