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

Eric Liu eliu at openjdk.java.net
Thu Sep 9 02:47:56 UTC 2021


On Wed, 8 Sep 2021 12:33:09 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:

>> src/hotspot/share/opto/mulnode.cpp line 211:
>> 
>>> 209:     Node* n21 = in2->in(1);
>>> 210:     if (phase->type(n11)->higher_equal(TypeInt::ZERO) &&
>>> 211:         phase->type(n21)->higher_equal(TypeInt::ZERO)) {
>> 
>> I was thinking if it's a good idea to move these code into MulNode, as they were actually much the same with MulLNode.
>
> I wonder that too, so is the rest of MulINode/MulLNode::Ideal() code (and many other places). I am not sure how to workaround the different types, any suggestions?

Just a dogfood, but it works. https://gist.github.com/theRealELiu/328d62157975b1f20e3626b3ef747eb4

Too much abstraction makes the code hard to read. One needs to check the concrete class to identify what the code exactly is, E.g.  In my patch, add_id() may be TypeInt::ZERO or TypeLong::Zero, even TypeD::ZERO.  So I'm not sure if it's a good idea. Is there any guidelines to this issue, try to abstract them or make the readability in the first place? @TobiHartmann

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

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


More information about the hotspot-compiler-dev mailing list