RFR: 8323220: Reassociate loop invariants involved in Cmps and Add/Subs [v3]

Xin Liu xliu at openjdk.org
Mon Jan 22 23:48:26 UTC 2024


On Mon, 22 Jan 2024 21:50:11 GMT, Joshua Cao <duke at openjdk.org> wrote:

>> test/hotspot/jtreg/compiler/loopopts/InvariantCodeMotionReassociateCmp.java line 163:
>> 
>>> 161:             }
>>> 162:         }
>>> 163:     }
>> 
>> Why could you not have random arguments here?
>
> [notEqualsInvariantSubVariantLong.txt](https://github.com/openjdk/jdk/files/14015703/notEqualsInvariantSubVariantLong.txt)
> 
> Attaching the IdealGraphVisualizer file (renamed to `.txt` cause GitHub wants that).
> 
> When we use `Argument.NUMBER_42`, we can avoid generating traps. When `i == 0` we enter the if statement, otherwise we exit.
> 
> If we use random numbers, we most likely never enter the if statement so we can generate a trap there. In this case, the trap block as an extra `SubL` for `inv1 - i`.

As long as you have inv1 == inv2, your comparison will have a different result when i == 0. 

Can you randomize just one value and use them for both inv1 and inv2?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17375#discussion_r1462561383


More information about the hotspot-compiler-dev mailing list