forked from openjdk/jdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8310886: C2 SuperWord: Two nodes should be isomorphic if they are loo…
…p invariant but pinned at different nodes outside the loop
- Loading branch information
1 parent
ed2b467
commit 21e95b2
Showing
3 changed files
with
113 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
test/hotspot/jtreg/compiler/loopopts/superword/TestMulAddS2I.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
/** | ||
* @test | ||
* @bug 8310886 | ||
* @summary Test MulAddS2I vectorization. | ||
* @library /test/lib / | ||
* @run driver compiler.loopopts.superword.TestMulAddS2I | ||
*/ | ||
|
||
package compiler.loopopts.superword; | ||
|
||
import compiler.lib.ir_framework.*; | ||
import jdk.test.lib.Asserts; | ||
import jdk.test.lib.Platform; | ||
|
||
public class TestMulAddS2I { | ||
static final int RANGE = 1024; | ||
static final int ITER = RANGE/2 - 1; | ||
|
||
static short[] sArr1 = new short[RANGE]; | ||
static short[] sArr2 = new short[RANGE]; | ||
static final int[] GOLDEN; | ||
|
||
static { | ||
for (int i = 0; i < RANGE; i++) { | ||
sArr1[i] = (short)(i + (1000 * AbstractInfo.getRandom().nextDouble())); | ||
sArr2[i] = (short)(RANGE - i + (2000 * AbstractInfo.getRandom().nextDouble())); | ||
} | ||
GOLDEN = test(); | ||
} | ||
|
||
|
||
public static void main(String[] args) { | ||
if (Platform.isX64() || Platform.isX86()) { | ||
TestFramework.runWithFlags("-XX:+UseUnalignedLoadStores"); | ||
TestFramework.runWithFlags("-XX:-UseUnalignedLoadStores"); | ||
} else { | ||
TestFramework.run(); | ||
} | ||
} | ||
|
||
@Run(test = "test") | ||
@Warmup(0) | ||
public static void run() { | ||
compare(test()); | ||
} | ||
|
||
public static void compare(int[] out) { | ||
for (int i = 0; i < ITER; i++) { | ||
Asserts.assertEQ(out[i], GOLDEN[i], "wrong result for out[" + i + "]"); | ||
} | ||
} | ||
|
||
@Test | ||
@IR(applyIfCPUFeature = {"sse2", "true"}, applyIf = {"UseUnalignedLoadStores", "true"}, | ||
counts = {IRNode.MUL_ADD_S2I, "> 0", IRNode.MUL_ADD_VS2VI, "> 0"}) | ||
@IR(applyIfCPUFeature = {"sse2", "true"}, applyIf = {"UseUnalignedLoadStores", "false"}, | ||
failOn = {IRNode.MUL_ADD_VS2VI}, // Can only pack LoadS if UseUnalignedLoadStores is true (default if sse4.2) | ||
counts = {IRNode.MUL_ADD_S2I, "> 0"}) | ||
@IR(applyIfCPUFeature = {"asimd", "true"}, applyIf = {"MaxVectorSize", "16"}, | ||
counts = {IRNode.MUL_ADD_S2I, "> 0", IRNode.MUL_ADD_VS2VI, "> 0"}) | ||
public static int[] test() { | ||
int[] out = new int[ITER]; | ||
int[] out2 = new int[ITER]; | ||
for (int i = 0; i < ITER; i++) { | ||
out[i] += ((sArr1[2*i] * sArr1[2*i]) + (sArr1[2*i+1] * sArr1[2*i+1])); | ||
out2[i] += out[i]; | ||
} | ||
return out; | ||
} | ||
} |