RFR: 8273454: C2: Transform (-a)*(-b) into a*b [v2]
Tobias Hartmann
thartmann at openjdk.java.net
Thu Sep 9 07:34:04 UTC 2021
On Thu, 9 Sep 2021 07:17:28 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:
>> 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
>
> Yes, I would also prefer to move the optimization into `MulNode::Ideal`. @theRealELiu's patch is good but can be further improved by modifying the node inputs instead of returning a new node (similar to the other optimizations in `MulNode::Ideal`).
Also, `Type::is_zero_type` can be used to detect 0 and instead of checking the opcodes, `Node::is_Sub` should be used.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5403
More information about the hotspot-compiler-dev
mailing list