RFR: 8313720: C2 SuperWord: wrong result with -XX:+UseVectorCmov -XX:+UseCMoveUnconditionally [v2]
Tobias Hartmann
thartmann at openjdk.org
Tue Aug 15 14:46:09 UTC 2023
On Tue, 15 Aug 2023 14:38:51 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.
>
> Emanuel Peter has updated the pull request incrementally with one additional commit since the last revision:
>
> review suggestions
Looks good to me.
-------------
Marked as reviewed by thartmann (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/15274#pullrequestreview-1578709488
More information about the hotspot-compiler-dev
mailing list