-
Bug
-
Resolution: Fixed
-
P3
-
11, 17, 18, 19
-
b21
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8288810 | 17.0.5-oracle | Tobias Hartmann | P3 | Resolved | Fixed | b01 |
JDK-8289121 | 17.0.5 | Goetz Lindenmaier | P3 | Resolved | Fixed | b01 |
JDK-8288812 | 11.0.17-oracle | Tobias Hartmann | P3 | Resolved | Fixed | b01 |
JDK-8289920 | 11.0.17 | Goetz Lindenmaier | P3 | Resolved | Fixed | b01 |
HOW TO REPRODUCE
$ java -ea Fail.java (using JDK 17, 18, or 19 up to b11)
FAILURE ANALYSIS
Using Fail.java as an example (run with -XX:-PartialPeelLoop for simplicity), the sequence of events is (roughly) as follows:
Original loop before loop optimizations (N, M, and Fail.mask are constants):
for (int i = 0; i < N; i++) {
for (j = 0; j < M; j++) {
r[i] ^= Fail.mask;
}
}
1. The inner loop is marked as a reduction together with its XOR operation:
for (int i = 0; i < N; i++) {
for (j = 0; j < M; j++) { // loop marked as a reduction
r[i] ^= Fail.mask; // XOR marked as a reduction
}
}
2. The inner loop is split into a peeled iteration, main, and post loop and unrolled twice:
for (int i = 0; i < N; i++) {
r[i] ^= Fail.mask; // XOR marked as a reduction (inconsistent, outer loop is not a reduction!)
int j = 0;
for (...; j+=2) { // loop marked as a reduction
r[i] ^= Fail.mask; // XOR marked as a reduction
r[i] ^= Fail.mask; // XOR marked as a reduction
}
for (...; j++) { // loop marked as a reduction
r[i] ^= Fail.mask; // XOR marked as a reduction
}
}
3. the inner main and post loops are found to be redundant (due to the "self-inversion" property of XOR with a constant operand) and get removed:
for (int i = 0; i < N; i++) {
r[i] ^= Fail.mask; // XOR marked as a reduction
}
4. the outer loop is further optimized into its final version, where the main loop is unrolled four times for SLP vectorization:
int i = 0;
for (...; i++) {
r[i] ^= Fail.mask; // XOR marked as a reduction
}
for (...; i+=4) {
r[i] ^= Fail.mask; // XOR marked as a reduction
r[i] ^= Fail.mask; // XOR marked as a reduction
r[i] ^= Fail.mask; // XOR marked as a reduction
r[i] ^= Fail.mask; // XOR marked as a reduction
}
for (...; i++) {
r[i] ^= Fail.mask; // XOR marked as a reduction
}
5. the main loop is wrongly vectorized as a reduction due to its XOR operations being marked as reductions:
int i = 0;
for (...; i++) {
r[i] ^= Fail.mask; // XOR marked as a reduction
}
for (...; i+=4) {
tmp = reduce(XOR, Fail.mask, r[i...i+3])
r[i...i+3] = [tmp, tmp, tmp, tmp]
}
for (...; i++) {
r[i] ^= Fail.mask; // XOR marked as a reduction
}
The expected main loop vectorization is:
...
for (...; i+=4) {
r[i...i+3] = map(XOR, r[i...i+3], [Fail.mask, Fail.mask, Fail.mask, Fail.mask])
}
...
Note that this failure is only reproducible in up to JDK 19 b11. In JDK 19 b12,
ORIGINAL REPORT:
The attached fuzzer test produces a different result for C2 compared to C1/interpreter.
To reproduce (on JDK 17, JDK18, and JDK19):
$ java -Xint Test.java > int.log
$ java Test.java > c2.log
$ diff int.log c2.log
55c55
< iArr3 = -4168
---
> iArr3 = -204359
67c67
< iArr3 = -4168
---
> iArr3 = -195060
# To reproduce on JDK 17, JDK 18 (but not on JDK19 commit cc7cf81):
$ java -ea Reduced.java
(results in an exception because of an unexpected result.)
# To reproduce on JDK19 commit cc7cf81:
$ java -ea Reduced2.java
(as above, results in an exception because of an unexpected result.)
- backported by
-
JDK-8288810 C2: miscompilation of map pattern as a vector reduction
- Resolved
-
JDK-8288812 C2: miscompilation of map pattern as a vector reduction
- Resolved
-
JDK-8289121 C2: miscompilation of map pattern as a vector reduction
- Resolved
-
JDK-8289920 C2: miscompilation of map pattern as a vector reduction
- Resolved
- relates to
-
JDK-8261147 C2: Node is wrongly marked as reduction resulting in a wrong execution due to wrong vector instructions
- Closed
-
JDK-8154302 C2 removes safepoint poll from loop
- Closed
-
JDK-8074981 Integer/FP scalar reduction optimization
- Resolved
-
JDK-8285369 C2: emit reduction flag value in node and loop dumps
- Resolved
-
JDK-8286177 C2: "failed: non-reduction loop contains reduction nodes" assert failure
- Resolved
-
JDK-8290964 C2 compilation fails with assert "non-reduction loop contains reduction nodes"
- Resolved
-
JDK-8271272 C2: assert(!had_error) failed: bad dominance
- Closed
-
JDK-8287087 C2: perform SLP reduction analysis on-demand
- Resolved
- links to
-
Commit openjdk/jdk11u-dev/4f1ac634
-
Commit openjdk/jdk17u-dev/47e478d6
-
Commit openjdk/jdk/6fcd3222
-
Review openjdk/jdk11u-dev/1194
-
Review openjdk/jdk17u-dev/494
-
Review openjdk/jdk18u/157
-
Review openjdk/jdk/8464