RFR: 8328865: [c2] No need to convert "(x+1)+y" into "(x+y)+1" when y is a CallNode [v2]

Emanuel Peter epeter at openjdk.org
Wed Mar 27 09:26:21 UTC 2024


On Wed, 27 Mar 2024 09:19:32 GMT, SUN Guoyun <duke at openjdk.org> wrote:

>> I think it is not a call node but (x+1) result is used by debug info of call node.
>> For example, next code could be the same issue (I did not verified it):
>> 
>>      static int y = 0;
>> ...
>>      int foo(int x, int z) {
>>          int a = x + 1;
>>          y = a;
>>          return a + z;
>>      }
>
>> I think it is not a call node but (x+1) result is used by debug info of call node. For example, next code could be the same issue (I did not verified it):
>> 
>> ```
>>      static int y = 0;
>> ...
>>      int foo(int x, int z) {
>>          int a = x + 1;
>>          y = a;
>>          return a + z;
>>      }
>> ```
> 
> Your example is correct and has the same issue. I will make further modifications.

@sunny868 do you have a benchmark where you can show the difference? Does spilling matter that much if we are already doing a call anyway?
I'm just worried that we prevent the constants from sinking down, and commoning (folding together) with other constants further down. In some cases this is also expected by patter matching in some optimizations, though there would surely be ways to improve those if need be.

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

PR Comment: https://git.openjdk.org/jdk/pull/18482#issuecomment-2022290380


More information about the hotspot-compiler-dev mailing list