Skip to content

Commit 9d5ae2e

Browse files
committed
8279076: C2: Bad AD file when matching SqrtF with UseSSE=0
Reviewed-by: kvn, sviswanathan
1 parent 04ee921 commit 9d5ae2e

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

src/hotspot/cpu/x86/x86.ad

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,16 @@ const bool Matcher::match_rule_supported(int opcode) {
16011601
return false;
16021602
}
16031603
break;
1604+
case Op_SqrtF:
1605+
if (UseSSE < 1) {
1606+
return false;
1607+
}
1608+
break;
1609+
case Op_SqrtD:
1610+
if (UseSSE < 2) {
1611+
return false;
1612+
}
1613+
break;
16041614
}
16051615
return true; // Match rules are supported by default.
16061616
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2021, Red Hat, Inc. 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.c2;
25+
26+
/*
27+
* @test
28+
* @bug 8279076
29+
* @summary SqrtD/SqrtF should be matched only on supported platforms
30+
* @requires vm.debug
31+
*
32+
* @run main/othervm -XX:-TieredCompilation -Xcomp
33+
* -XX:CompileOnly=compiler/c2/TestSqrt
34+
* -XX:CompileOnly=java/lang/Math
35+
* compiler.c2.TestSqrt
36+
*/
37+
public class TestSqrt {
38+
static float srcF = 42.0f;
39+
static double srcD = 42.0d;
40+
static float dstF;
41+
static double dstD;
42+
43+
public static void test() {
44+
dstF = (float)Math.sqrt((double)srcF);
45+
dstD = Math.sqrt(srcD);
46+
}
47+
48+
public static void main(String args[]) {
49+
for (int i = 0; i < 20_000; i++) {
50+
test();
51+
}
52+
}
53+
}
54+

0 commit comments

Comments
 (0)