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

Emanuel Peter epeter at openjdk.org
Tue Aug 15 13:28:15 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.

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

Commit messages:
 - fix after merge for vector size
 - Merge branch 'master' into JDK-8313720
 - remove simple test
 - add IR tests
 - 8313720: C2 SuperWord: wrong result with -XX:+UseVectorCmov -XX:+UseCMoveUnconditionally

Changes: https://git.openjdk.org/jdk/pull/15274/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15274&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8313720
  Stats: 173 lines in 2 files changed: 164 ins; 0 del; 9 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