RFR: 8313720: C2 SuperWord: wrong result with -XX:+UseVectorCmov -XX:+UseCMoveUnconditionally [v2]

Emanuel Peter epeter at openjdk.org
Tue Aug 15 14:38:51 UTC 2023


> **Problem**
> 
> In my recent fix of [JDK-8306302](https://bugs.openjdk.org/browse/JDK-8306302) I forgot to check that the `Bool` node in the `Cmp -> Bool -> CMove` complex must have the same test value for all `Bool` nodes in the pack. Without that check, we fail to see the difference between:
> 
> https://github.com/openjdk/jdk/blob/6d545b1580e0b3df9bc01bd64bd1a616c6ceeb9b/test/hotspot/jtreg/compiler/c2/irTests/TestVectorConditionalMove.java#L354-L357
> 
> https://github.com/openjdk/jdk/blob/6d545b1580e0b3df9bc01bd64bd1a616c6ceeb9b/test/hotspot/jtreg/compiler/c2/irTests/TestVectorConditionalMove.java#L384-L387
> 
> While the first hand-unrolled example has the same test value (tl) in both lines (packing ok) the second example has different test values (lt and le). Before this fix we would just assume they have the same test value, and therefore also use lt for the second line as a consequence. That can lead to wrong results.
> 
> **Solution**
> 
> `SuperWord::isomorphic` should return `false` if two `Bool` nodes do not have the same test value. That ensures that only `Bool` nodes with the same test value will ever be packed, since isomorphism is a requirement for packing.
> 
> In addition, I also added verification code in `SuperWord::output`, just before we turn the `Cmp -> Bool -> CMove` scalar nodes into vector nodes.
> 
> **Testing**
> 
> Added Regression Test. Ran Tier1-6 + stress-testing.

Emanuel Peter has updated the pull request incrementally with one additional commit since the last revision:

  review suggestions

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/15274/files
  - new: https://git.openjdk.org/jdk/pull/15274/files/a70951cf..a827c9fe

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=15274&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15274&range=00-01

  Stats: 2 lines in 2 files changed: 0 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/15274.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15274/head:pull/15274

PR: https://git.openjdk.org/jdk/pull/15274


More information about the hotspot-compiler-dev mailing list