RFR: 8313720: C2 SuperWord: wrong result with -XX:+UseVectorCmov -XX:+UseCMoveUnconditionally
Christian Hagedorn
chagedorn at openjdk.org
Tue Aug 15 14:02:08 UTC 2023
On Mon, 14 Aug 2023 14:57:39 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
> **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.
Apart from Tobias' suggestion, the fix looks good!
You could also add the bug number of this fix to the `@bug` in the JTreg test.
-------------
Marked as reviewed by chagedorn (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/15274#pullrequestreview-1578619983
More information about the hotspot-compiler-dev
mailing list