Skip to content

Commit aa36799

Browse files
author
Vladimir Ivanov
committed
8367333: C2: Vector math operation intrinsification failure
Reviewed-by: epeter, shade, jbhateja
1 parent 919f5fa commit aa36799

File tree

3 files changed

+167
-0
lines changed

3 files changed

+167
-0
lines changed

src/hotspot/share/prims/vectorSupport.cpp

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

595+
case VECTOR_OP_TAN: // fall-through
596+
case VECTOR_OP_TANH: // fall-through
597+
case VECTOR_OP_SIN: // fall-through
598+
case VECTOR_OP_SINH: // fall-through
599+
case VECTOR_OP_COS: // fall-through
600+
case VECTOR_OP_COSH: // fall-through
601+
case VECTOR_OP_ASIN: // fall-through
602+
case VECTOR_OP_ACOS: // fall-through
603+
case VECTOR_OP_ATAN: // fall-through
604+
case VECTOR_OP_ATAN2: // fall-through
605+
case VECTOR_OP_CBRT: // fall-through
606+
case VECTOR_OP_LOG: // fall-through
607+
case VECTOR_OP_LOG10: // fall-through
608+
case VECTOR_OP_LOG1P: // fall-through
609+
case VECTOR_OP_POW: // fall-through
610+
case VECTOR_OP_EXP: // fall-through
611+
case VECTOR_OP_EXPM1: // fall-through
612+
case VECTOR_OP_HYPOT: return 0; // not supported; should be handled in Java code
613+
595614
default: fatal("unknown op: %d", vop);
596615
}
597616
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: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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 -XX:+StressIncrementalInlining -XX:CompileCommand=quiet
38+
* -XX:CompileCommand=compileonly,compiler.vectorapi.TestVectorMathLib::test*
39+
* compiler.vectorapi.TestVectorMathLib
40+
*/
41+
42+
public class TestVectorMathLib {
43+
private static final VectorSpecies SPECIES = FloatVector.SPECIES_PREFERRED;
44+
45+
static FloatVector testTAN(FloatVector fv) {
46+
return fv.lanewise(VectorOperators.TAN);
47+
}
48+
static FloatVector testTANH(FloatVector fv) {
49+
return fv.lanewise(VectorOperators.TANH);
50+
}
51+
static FloatVector testSIN(FloatVector fv) {
52+
return fv.lanewise(VectorOperators.SIN);
53+
}
54+
static FloatVector testSINH(FloatVector fv) {
55+
return fv.lanewise(VectorOperators.SINH);
56+
}
57+
static FloatVector testCOS(FloatVector fv) {
58+
return fv.lanewise(VectorOperators.COS);
59+
}
60+
static FloatVector testCOSH(FloatVector fv) {
61+
return fv.lanewise(VectorOperators.COSH);
62+
}
63+
static FloatVector testASIN(FloatVector fv) {
64+
return fv.lanewise(VectorOperators.ASIN);
65+
}
66+
static FloatVector testACOS(FloatVector fv) {
67+
return fv.lanewise(VectorOperators.ACOS);
68+
}
69+
static FloatVector testATAN(FloatVector fv) {
70+
return fv.lanewise(VectorOperators.ATAN);
71+
}
72+
static FloatVector testATAN2(FloatVector fv) {
73+
return fv.lanewise(VectorOperators.ATAN2, fv);
74+
}
75+
static FloatVector testCBRT(FloatVector fv) {
76+
return fv.lanewise(VectorOperators.CBRT);
77+
}
78+
static FloatVector testLOG(FloatVector fv) {
79+
return fv.lanewise(VectorOperators.LOG);
80+
}
81+
static FloatVector testLOG10(FloatVector fv) {
82+
return fv.lanewise(VectorOperators.LOG10);
83+
}
84+
static FloatVector testLOG1P(FloatVector fv) {
85+
return fv.lanewise(VectorOperators.LOG1P);
86+
}
87+
static FloatVector testPOW(FloatVector fv) {
88+
return fv.lanewise(VectorOperators.POW, fv);
89+
}
90+
static FloatVector testEXP(FloatVector fv) {
91+
return fv.lanewise(VectorOperators.EXP);
92+
}
93+
static FloatVector testEXPM1(FloatVector fv) {
94+
return fv.lanewise(VectorOperators.EXPM1);
95+
}
96+
static FloatVector testHYPOT(FloatVector fv) {
97+
return fv.lanewise(VectorOperators.HYPOT, fv);
98+
}
99+
100+
public static void main(String[] args) {
101+
FloatVector z = FloatVector.zero(SPECIES);
102+
for (int i = 0; i < 20_000; i++) {
103+
z.neg(); // unary
104+
z.add(z); // binary
105+
106+
testTAN(z);
107+
testTANH(z);
108+
testSIN(z);
109+
testSINH(z);
110+
testCOS(z);
111+
testCOSH(z);
112+
testASIN(z);
113+
testACOS(z);
114+
testATAN(z);
115+
testATAN2(z);
116+
testCBRT(z);
117+
testLOG(z);
118+
testLOG10(z);
119+
testLOG1P(z);
120+
testPOW(z);
121+
testEXP(z);
122+
testEXPM1(z);
123+
testHYPOT(z);
124+
}
125+
126+
System.out.println("TEST PASSED");
127+
}
128+
}
129+

0 commit comments

Comments
 (0)