RFR: 8279622: C2: miscompilation of map pattern as a vector reduction

Roberto Castañeda Lozano rcastanedalo at openjdk.java.net
Fri Apr 29 11:01:11 UTC 2022


The node reduction flag (`Node::Flag_is_reduction`) is only valid as long as the node remains within the reduction loop in which it was originally marked. This changeset ensures that reduction nodes are unmarked as such if they are extracted out of their associated reduction loop by the peel/main/post loop transformation (`PhaseIdealLoop::insert_pre_post_loops()`). This prevents SLP from wrongly vectorizing, as parallel reductions, outer non-reduction loops to which reduction nodes have been extracted. A more detailed analysis of the failure is available in the [JBS bug report](https://bugs.openjdk.java.net/browse/JDK-8279622).

The issue could be alternatively fixed at the IGVN level by unmarking reduction nodes as soon as they are decoupled from their corresponding phi and counted loop nodes, but the fix proposed here is simpler and less intrusive.

The changeset also introduces an assertion at the use point (`SuperWord::transform_loop()`) to check that loops containing reduction nodes are marked as reductions. This invariant could be alternatively placed together with other assertions under `-XX:+VerifyLoopOptimizations`, but [this option is known to be broken](https://bugs.openjdk.java.net/browse/JDK-8173709).

IR verification using the IR test framework is not feasible for the proposed test case, since the failure is triggered on a OSR compilation, [for which IR verification does not seem to be supported](https://github.com/openjdk/jdk/blob/e7c3b9de649d4b28ba16844e042afcf3c89323e5/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/Line.java#L56-L58). The assertion described above compensates this limitation.

#### Testing

##### Functionality

- hs-tier1-3 (windows-x64, linux-x64, linux-aarch64, and macosx-x64; release and debug mode).
- hs-tier4-7 (linux-x64; debug mode).

##### Performance

- No significant regression on a set of standard benchmark suites (DaCapo, SPECjbb2015, SPECjvm2008, ...) and on windows-x64, linux-x64, linux-aarch64, and macosx-x64.
- No significant difference in generated number of vector instructions when comparing the output of `compiler/vectorization` and `compiler/loopopts/superword` tests using `-XX:+TraceNewVectors` on linux-x64.

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

Commit messages:
 - Apply simpler solution at the loop transformation level
 - Add modified reduction node to the IGVN worklist
 - Remove reduction mark from peeled nodes

Changes: https://git.openjdk.java.net/jdk/pull/8464/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=8464&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8279622
  Stats: 95 lines in 5 files changed: 95 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8464.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8464/head:pull/8464

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


More information about the hotspot-compiler-dev mailing list