Skip to content

Commit 6c751f2

Browse files
committed
8367333: C2: Vector math operation intrinsification failure
8367969: C2: compiler/vectorapi/TestVectorMathLib.java fails without UnlockDiagnosticVMOptions Reviewed-by: eastigeevich, phh Backport-of: aa36799acb5834d730400fb073a9a3a8ee3c28ef
1 parent 668808f commit 6c751f2

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed

src/hotspot/share/prims/vectorSupport.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,25 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) {
593593
break;
594594
}
595595

596+
case VECTOR_OP_TAN: // fall-through
597+
case VECTOR_OP_TANH: // fall-through
598+
case VECTOR_OP_SIN: // fall-through
599+
case VECTOR_OP_SINH: // fall-through
600+
case VECTOR_OP_COS: // fall-through
601+
case VECTOR_OP_COSH: // fall-through
602+
case VECTOR_OP_ASIN: // fall-through
603+
case VECTOR_OP_ACOS: // fall-through
604+
case VECTOR_OP_ATAN: // fall-through
605+
case VECTOR_OP_ATAN2: // fall-through
606+
case VECTOR_OP_CBRT: // fall-through
607+
case VECTOR_OP_LOG: // fall-through
608+
case VECTOR_OP_LOG10: // fall-through
609+
case VECTOR_OP_LOG1P: // fall-through
610+
case VECTOR_OP_POW: // fall-through
611+
case VECTOR_OP_EXP: // fall-through
612+
case VECTOR_OP_EXPM1: // fall-through
613+
case VECTOR_OP_HYPOT: return 0; // not supported; should be handled in Java code
614+
596615
default: fatal("unknown op: %d", vop);
597616
}
598617
return 0; // Unimplemented

src/hotspot/share/prims/vectorSupport.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,25 @@ class VectorSupport : AllStatic {
101101
VECTOR_OP_COMPRESS_BITS = 33,
102102
VECTOR_OP_EXPAND_BITS = 34,
103103

104+
VECTOR_OP_TAN = 101,
105+
VECTOR_OP_TANH = 102,
106+
VECTOR_OP_SIN = 103,
107+
VECTOR_OP_SINH = 104,
108+
VECTOR_OP_COS = 105,
109+
VECTOR_OP_COSH = 106,
110+
VECTOR_OP_ASIN = 107,
111+
VECTOR_OP_ACOS = 108,
112+
VECTOR_OP_ATAN = 109,
113+
VECTOR_OP_ATAN2 = 110,
114+
VECTOR_OP_CBRT = 111,
115+
VECTOR_OP_LOG = 112,
116+
VECTOR_OP_LOG10 = 113,
117+
VECTOR_OP_LOG1P = 114,
118+
VECTOR_OP_POW = 115,
119+
VECTOR_OP_EXP = 116,
120+
VECTOR_OP_EXPM1 = 117,
121+
VECTOR_OP_HYPOT = 118,
122+
104123
VECTOR_OP_SADD = 119,
105124
VECTOR_OP_SSUB = 120,
106125
VECTOR_OP_SUADD = 121,
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
package compiler.vectorapi;
25+
26+
import jdk.incubator.vector.FloatVector;
27+
import jdk.incubator.vector.VectorOperators;
28+
import jdk.incubator.vector.VectorSpecies;
29+
30+
/*
31+
* @test
32+
* @bug 8367333
33+
* @requires vm.compiler2.enabled
34+
* @modules jdk.incubator.vector
35+
* @library /test/lib
36+
*
37+
* @run main/othervm -Xbatch -XX:-TieredCompilation
38+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressIncrementalInlining
39+
* -XX:CompileCommand=quiet
40+
* -XX:CompileCommand=compileonly,compiler.vectorapi.TestVectorMathLib::test*
41+
* compiler.vectorapi.TestVectorMathLib
42+
*/
43+
44+
public class TestVectorMathLib {
45+
private static final VectorSpecies SPECIES = FloatVector.SPECIES_PREFERRED;
46+
47+
static FloatVector testTAN(FloatVector fv) {
48+
return fv.lanewise(VectorOperators.TAN);
49+
}
50+
static FloatVector testTANH(FloatVector fv) {
51+
return fv.lanewise(VectorOperators.TANH);
52+
}
53+
static FloatVector testSIN(FloatVector fv) {
54+
return fv.lanewise(VectorOperators.SIN);
55+
}
56+
static FloatVector testSINH(FloatVector fv) {
57+
return fv.lanewise(VectorOperators.SINH);
58+
}
59+
static FloatVector testCOS(FloatVector fv) {
60+
return fv.lanewise(VectorOperators.COS);
61+
}
62+
static FloatVector testCOSH(FloatVector fv) {
63+
return fv.lanewise(VectorOperators.COSH);
64+
}
65+
static FloatVector testASIN(FloatVector fv) {
66+
return fv.lanewise(VectorOperators.ASIN);
67+
}
68+
static FloatVector testACOS(FloatVector fv) {
69+
return fv.lanewise(VectorOperators.ACOS);
70+
}
71+
static FloatVector testATAN(FloatVector fv) {
72+
return fv.lanewise(VectorOperators.ATAN);
73+
}
74+
static FloatVector testATAN2(FloatVector fv) {
75+
return fv.lanewise(VectorOperators.ATAN2, fv);
76+
}
77+
static FloatVector testCBRT(FloatVector fv) {
78+
return fv.lanewise(VectorOperators.CBRT);
79+
}
80+
static FloatVector testLOG(FloatVector fv) {
81+
return fv.lanewise(VectorOperators.LOG);
82+
}
83+
static FloatVector testLOG10(FloatVector fv) {
84+
return fv.lanewise(VectorOperators.LOG10);
85+
}
86+
static FloatVector testLOG1P(FloatVector fv) {
87+
return fv.lanewise(VectorOperators.LOG1P);
88+
}
89+
static FloatVector testPOW(FloatVector fv) {
90+
return fv.lanewise(VectorOperators.POW, fv);
91+
}
92+
static FloatVector testEXP(FloatVector fv) {
93+
return fv.lanewise(VectorOperators.EXP);
94+
}
95+
static FloatVector testEXPM1(FloatVector fv) {
96+
return fv.lanewise(VectorOperators.EXPM1);
97+
}
98+
static FloatVector testHYPOT(FloatVector fv) {
99+
return fv.lanewise(VectorOperators.HYPOT, fv);
100+
}
101+
102+
public static void main(String[] args) {
103+
FloatVector z = FloatVector.zero(SPECIES);
104+
for (int i = 0; i < 20_000; i++) {
105+
z.neg(); // unary
106+
z.add(z); // binary
107+
108+
testTAN(z);
109+
testTANH(z);
110+
testSIN(z);
111+
testSINH(z);
112+
testCOS(z);
113+
testCOSH(z);
114+
testASIN(z);
115+
testACOS(z);
116+
testATAN(z);
117+
testATAN2(z);
118+
testCBRT(z);
119+
testLOG(z);
120+
testLOG10(z);
121+
testLOG1P(z);
122+
testPOW(z);
123+
testEXP(z);
124+
testEXPM1(z);
125+
testHYPOT(z);
126+
}
127+
128+
System.out.println("TEST PASSED");
129+
}
130+
}
131+

0 commit comments

Comments
 (0)