RFR: 8273021: C2: Improve Add and Xor ideal optimizations [v3]

Yi Yang yyang at openjdk.java.net
Wed Sep 8 05:56:53 UTC 2021


On Thu, 2 Sep 2021 14:08:49 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:

>> Yi Yang has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - dontinline
>>  - more random
>
> src/hotspot/share/opto/addnode.cpp line 1014:
> 
>> 1012:       return new SubINode(phase->makecon(TypeInt::ZERO), in1->in(1));
>> 1013:     }
>> 1014:   } else if (op2 == Op_AddI && phase->type(in1) == TypeInt::MINUS_1) {
> 
> Why do you need to check both inputs for constant -1? Shouldn't `AddNode::Ideal` canonicalize the inputs and ensure that constants are moved to the second input? 
> 
> https://github.com/openjdk/jdk/blob/599d07c0db9c85e4dae35d1c54a63407d32eaedd/src/hotspot/share/opto/addnode.hpp#L52-L54

Indeed, `commute` already moves loads and constants into right .

Changed.

> test/hotspot/jtreg/compiler/c2/TestAddXorIdeal.java line 30:
> 
>> 28:  * @summary C2: Improve Add and Xor ideal optimizations
>> 29:  * @library /test/lib
>> 30:  * @run main/othervm -XX:-Inline -XX:-TieredCompilation -XX:TieredStopAtLevel=4 -XX:CompileCommand=compileonly,compiler.c2.TestAddXorIdeal::* compiler.c2.TestAddXorIdeal
> 
> What about `-XX:CompileCommand=dontinline,compiler.c2.TestAddXorIdeal::test*` Instead of disabling all inlining and limiting compilation?

Changed. Magic number have been substituted by random number.

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

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


More information about the hotspot-compiler-dev mailing list