RFR: 8274060: C2: Incorrect computation after JDK-8273454
Christian Hagedorn
chagedorn at openjdk.java.net
Tue Sep 21 13:59:37 UTC 2021
On Tue, 21 Sep 2021 13:13:37 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> A Fuzzer test caught a serious regression after [JDK-8273454](https://bugs.openjdk.java.net/browse/JDK-8273454): the results are different in (interpreter, C1) vs C2. See the original test cases in the bug. I believe the trouble is due to `And*Node`-s sharing code with `MulNode` (for [reasons](https://github.com/openjdk/jdk/blob/42d5d2abaad8a88a5e1326ea8b4494aeb8b5748b/src/hotspot/share/opto/mulnode.hpp#L168-L169)), which means we enter the new transformation here:
>
>
> Node *AndINode::Ideal(PhaseGVN *phase, bool can_reshape) {
> // Special case constant AND mask
> const TypeInt *t2 = phase->type( in(2) )->isa_int();
> if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape); // <--- calls new code through here
>
>
> So while new optimization `((-x) * (-y)) => (x * y)` is correct, doing the same for `((-x) & (-y)) => (x & y)` is not!
>
> I opted to test the opcodes directly instead of introducing virtual methods in `MulNode`. Let me know if you prefer otherwise.
>
> Additional testing:
> - [x] Original tests now pass
> - [x] New regression test is copied from original for JDK-8273454, but new copy verifies that `&` operate the same (fails without the C2 fix)
> - [ ] `tier1` tests
Looks good!
-------------
Marked as reviewed by chagedorn (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/5612
More information about the hotspot-compiler-dev
mailing list