RFR: 8277882: New subnode ideal optimization: converting "c0 - (x + c1)" into "(c0 - c1) - x" [v4]

Mai Đặng Quân Anh duke at openjdk.java.net
Wed Dec 1 13:47:25 UTC 2021


On Tue, 30 Nov 2021 22:44:59 GMT, Zang, Zhiqiang <duke at openjdk.java.net> wrote:

>> Suggest two new optimizations that can be done in SubINode::Ideal.
>
> Zang, Zhiqiang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   add ok_to_convert to the condition.

src/hotspot/share/opto/subnode.cpp line 198:

> 196:       && phase->type(in2->in(2))->isa_int() != NULL
> 197:       && phase->type(in2->in(2))->isa_int()->is_con()
> 198:       && ok_to_convert(in2)) {

`ok_to_convert` should go right after `in2->Opcode() == Op_AddI` for uniformity. Also you could reuse the method `ok_to_convert(Node*, Node*)` for this, just feed `in1` as the second argument similar to the check in line 218.

test/hotspot/jtreg/compiler/c2/TestSubIdeal.java line 1:

> 1: /*

You missed the copyright header here, the same for the microbenchmark

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

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


More information about the hotspot-compiler-dev mailing list