Integrated: 8279622: C2: miscompilation of map pattern as a vector reduction
Roberto Castañeda Lozano
rcastanedalo at openjdk.java.net
Tue May 3 11:12:14 UTC 2022
On Fri, 29 Apr 2022 08:02:07 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:
> 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.
This pull request has now been integrated.
Changeset: 6fcd3222
Author: Roberto Castañeda Lozano <rcastanedalo at openjdk.org>
URL: https://git.openjdk.java.net/jdk/commit/6fcd322258e0cce3724a4a8dc18f7802018a7cc9
Stats: 95 lines in 5 files changed: 95 ins; 0 del; 0 mod
8279622: C2: miscompilation of map pattern as a vector reduction
Reviewed-by: roland, kvn, thartmann
-------------
PR: https://git.openjdk.java.net/jdk/pull/8464
More information about the hotspot-compiler-dev
mailing list