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

Emanuel Peter epeter at openjdk.org
Wed Aug 16 07:18:19 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.

This pull request has now been integrated.

Changeset: d46f0fb3
Author:    Emanuel Peter <epeter at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/d46f0fb31888db75f5b2b78a162fec16dfc5d0d9
Stats:     174 lines in 2 files changed: 164 ins; 0 del; 10 mod

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

Reviewed-by: chagedorn, thartmann

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

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


More information about the hotspot-compiler-dev mailing list