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

Xin Liu xliu at openjdk.org
Wed Jan 24 03:18:28 UTC 2024


On Tue, 23 Jan 2024 18:34:13 GMT, Joshua Cao <duke at openjdk.org> wrote:

>> I think CmpNode has the same re-association rule as SubNode. 
>> take your own example, 
>>>  inv1 == (x - inv2) => ( inv1 + inv2 ) == x
>> 
>> Cmp(inv1, (x-inv2)) => Eq(0, Sub(inv1, (x-inv2)) => Eq(0, Sub(inv1+inv2, x)) => Cmp(inv1+inv2, x)
>> 
>> Originally, n1->is_Sub() covers both CmpNode and SubNode. I don't you need to split them it into 2 cases. 
>> 
>> I think you only to check if n1 Cmp or Sub when you are going to return Cmp/SubNode
>
> The rules are not always the same. For example
> 
>> inv1 - (inv2 - x)     => (inv1 - inv2) + x
>> inv1  == (inv2 - x) => (-inv1 + inv2) == x
> 
> The signs of inv1 and inv2 are flipped. I don't think we can fold these into a single conditional

okay. I see you mean.

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

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


More information about the hotspot-compiler-dev mailing list