RFR: 8273454: C2: Transform (-a)*(-b) into a*b [v3]

Tobias Hartmann thartmann at openjdk.java.net
Thu Sep 9 13:48:09 UTC 2021


On Thu, 9 Sep 2021 13:25:38 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:

>> The transformation reduce instructions in generated code.
>> 
>> ### x86_64:
>> 
>> Before:
>> ```  
>>   0x00007fb92c78b3ac:   neg    %esi
>>   0x00007fb92c78b3ae:   neg    %edx
>>   0x00007fb92c78b3b0:   mov    %esi,%eax
>>   0x00007fb92c78b3b2:   imul   %edx,%eax                    ;*imul {reexecute=0 rethrow=0 return_oop=0}
>>                                                             ; - TestSub::runSub at 4 (line 9)
>> 
>> After:
>> 
>>                                                            ; - TestSub::runSub at -1 (line 9)
>>   0x00007fc8c05b74ac:   mov    %esi,%eax
>>   0x00007fc8c05b74ae:   imul   %edx,%eax                    ;*imul {reexecute=0 rethrow=0 return_oop=0}
>>                                                             ; - TestSub::runSub at 4 (line 9)
>> 
>> 
>> 
>> ### AArch64:
>> Before:
>> 
>>  0x0000ffff814b4a70:   neg     w11, w1
>>  0x0000ffff814b4a74:   mneg    w0, w2, w11                 ;*imul {reexecute=0 rethrow=0 return_oop=0}
>>                                                             ; - TestSub::runSub at 4 (line 9)
>> 
>> 
>> After:
>> 
>>  0x0000ffff794a67f0:   mul     w0, w1, w2                  ;*imul {reexecute=0 rethrow=0 return_oop=0}
>>                                                             ; - TestSub::runSub at 4 (line 9)
>
> Zhengyu Gu has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
> 
>  - Spacing
>  - Merge branch 'master' into JDK-8273454-neg-mul
>  - @theRealELiu and @TobiHartmann's comments
>  - Fix test
>  - Merge branch 'master' into JDK-8273454-neg-mul
>  - v1
>  - v0

Changes requested by thartmann (Reviewer).

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

> 72:     if (phase->type(n11)->is_zero_type() &&
> 73:         phase->type(n21)->is_zero_type()) {
> 74:       return make(in1->in(2), in2->in(2));

Why do you need to create a new node? Can't you simply update the inputs like the code below does?

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

PR: https://git.openjdk.java.net/jdk/pull/5403


More information about the hotspot-compiler-dev mailing list