RFR: 8274060: C2: Incorrect computation after JDK-8273454

Aleksey Shipilev shade at openjdk.java.net
Tue Sep 21 13:25:01 UTC 2021


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`, 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, but 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 copied duplicates one for JDK-8273454, but it verifies that `&` are not broken
 - [ ] `tier1` tests

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

Commit messages:
 - Fix

Changes: https://git.openjdk.java.net/jdk/pull/5612/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5612&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8274060
  Stats: 85 lines in 2 files changed: 82 ins; 1 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/5612.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/5612/head:pull/5612

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


More information about the hotspot-compiler-dev mailing list