Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit e93cd7e

Browse files
author
Yang Zhang
committedApr 29, 2020
8243155: AArch64: Add support for SqrtVF
Reviewed-by: aph
1 parent d813a88 commit e93cd7e

File tree

3 files changed

+85
-3
lines changed

3 files changed

+85
-3
lines changed
 

‎src/hotspot/cpu/aarch64/aarch64.ad

+23-1
Original file line numberDiff line numberDiff line change
@@ -13227,7 +13227,7 @@ instruct sqrtD_reg(vRegD dst, vRegD src) %{
1322713227
%}
1322813228

1322913229
instruct sqrtF_reg(vRegF dst, vRegF src) %{
13230-
match(Set dst (ConvD2F (SqrtD (ConvF2D src))));
13230+
match(Set dst (SqrtF src));
1323113231

1323213232
ins_cost(INSN_COST * 50);
1323313233
format %{ "fsqrts $dst, $src" %}
@@ -17041,6 +17041,28 @@ instruct vdiv2D(vecX dst, vecX src1, vecX src2)
1704117041

1704217042
// --------------------------------- SQRT -------------------------------------
1704317043

17044+
instruct vsqrt2F(vecD dst, vecD src)
17045+
%{
17046+
predicate(n->as_Vector()->length() == 2);
17047+
match(Set dst (SqrtVF src));
17048+
format %{ "fsqrt $dst, $src\t# vector (2F)" %}
17049+
ins_encode %{
17050+
__ fsqrt(as_FloatRegister($dst$$reg), __ T2S, as_FloatRegister($src$$reg));
17051+
%}
17052+
ins_pipe(vunop_fp64);
17053+
%}
17054+
17055+
instruct vsqrt4F(vecX dst, vecX src)
17056+
%{
17057+
predicate(n->as_Vector()->length() == 4);
17058+
match(Set dst (SqrtVF src));
17059+
format %{ "fsqrt $dst, $src\t# vector (4F)" %}
17060+
ins_encode %{
17061+
__ fsqrt(as_FloatRegister($dst$$reg), __ T4S, as_FloatRegister($src$$reg));
17062+
%}
17063+
ins_pipe(vsqrt_fp128);
17064+
%}
17065+
1704417066
instruct vsqrt2D(vecX dst, vecX src)
1704517067
%{
1704617068
predicate(n->as_Vector()->length() == 2);

‎test/hotspot/jtreg/compiler/c2/cr6340864/TestDoubleVect.java

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -90,6 +90,7 @@ static int test() {
9090
test_rint(a0, a1);
9191
test_ceil(a0, a1);
9292
test_floor(a0, a1);
93+
test_sqrt(a0, a1);
9394
}
9495
// Test and verify results
9596
System.out.println("Verification");
@@ -404,6 +405,22 @@ static int test() {
404405
errn += verify("test_rint_cc: ", 0, other_corner_cases_res[0], -0.0);
405406
errn += verify("test_rint_cc: ", 1, other_corner_cases_res[1], 0.0);
406407
errn += verify("test_rint_cc: ", 2, other_corner_cases_res[2], 9.007199254740992E15);
408+
409+
// Overwrite with +0.0/-0.0 values
410+
a1[6] = (double)0.0;
411+
a1[7] = (double)-0.0;
412+
test_sqrt(a0, a1);
413+
errn += verify("test_sqrt: ", 0, a0[0], (Double.NaN));
414+
errn += verify("test_sqrt: ", 1, a0[1], (Double.POSITIVE_INFINITY));
415+
errn += verify("test_sqrt: ", 2, a0[2], (Double.NaN));
416+
errn += verify("test_sqrt: ", 3, a0[3], Math.sqrt(Double.MAX_VALUE));
417+
errn += verify("test_sqrt: ", 4, a0[4], Math.sqrt(Double.MIN_VALUE));
418+
errn += verify("test_sqrt: ", 5, a0[5], Math.sqrt(Double.MIN_NORMAL));
419+
errn += verify("test_sqrt: ", 6, a0[6], (double)0.0);
420+
errn += verify("test_sqrt: ", 7, a0[7], (double)-0.0);
421+
for (int i=8; i<ARRLEN; i++) {
422+
errn += verify("test_sqrt: ", i, a0[i], Math.sqrt((double)(ADD_INIT+i)));
423+
}
407424
}
408425

409426
if (errn > 0)
@@ -540,6 +557,13 @@ static int test() {
540557
end = System.currentTimeMillis();
541558
System.out.println("test_negc_n: " + (end - start));
542559

560+
start = System.currentTimeMillis();
561+
for (int i=0; i<ITERS; i++) {
562+
test_sqrt(a0, a1);
563+
}
564+
end = System.currentTimeMillis();
565+
System.out.println("test_sqrt_n: " + (end - start));
566+
543567
return errn;
544568
}
545569

@@ -661,6 +685,12 @@ static void test_floor_cc(double[] a0, double[] a1) {
661685
}
662686
}
663687

688+
static void test_sqrt(double[] a0, double[] a1) {
689+
for (int i = 0; i < a0.length; i+=1) {
690+
a0[i] = (double)(Math.sqrt((double)a1[i]));
691+
}
692+
}
693+
664694
static int verify(String text, int i, double elem, double val) {
665695
if (elem != val && !(Double.isNaN(elem) && Double.isNaN(val))) {
666696
System.err.println(text + "[" + i + "] = " + elem + " != " + val);

‎test/hotspot/jtreg/compiler/c2/cr6340864/TestFloatVect.java

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -87,6 +87,7 @@ static int test() {
8787
test_divv(a0, a1, -VALUE);
8888
test_diva(a0, a1, a3);
8989
test_negc(a0, a1);
90+
test_sqrt(a0, a1);
9091
}
9192
// Test and verify results
9293
System.out.println("Verification");
@@ -352,6 +353,22 @@ static int test() {
352353
errn += verify("test_negc: ", i, a0[i], (float)(-((float)(ADD_INIT+i))));
353354
}
354355

356+
// Overwrite with +0.0/-0.0 values
357+
a1[6] = (float)0.0;
358+
a1[7] = (float)-0.0;
359+
test_sqrt(a0, a1);
360+
errn += verify("test_sqrt: ", 0, a0[0], (Float.NaN));
361+
errn += verify("test_sqrt: ", 1, a0[1], (Float.POSITIVE_INFINITY));
362+
errn += verify("test_sqrt: ", 2, a0[2], (Float.NaN));
363+
errn += verify("test_sqrt: ", 3, a0[3], (float)(Math.sqrt((double)Float.MAX_VALUE)));
364+
errn += verify("test_sqrt: ", 4, a0[4], (float)(Math.sqrt((double)Float.MIN_VALUE)));
365+
errn += verify("test_sqrt: ", 5, a0[5], (float)(Math.sqrt((double)Float.MIN_NORMAL)));
366+
errn += verify("test_sqrt: ", 6, a0[6], (float)0.0);
367+
errn += verify("test_sqrt: ", 7, a0[7], (float)-0.0);
368+
for (int i=8; i<ARRLEN; i++) {
369+
errn += verify("test_sqrt: ", i, a0[i], (float)(Math.sqrt((double)(ADD_INIT+i))));
370+
}
371+
355372
}
356373

357374
if (errn > 0)
@@ -488,6 +505,13 @@ static int test() {
488505
end = System.currentTimeMillis();
489506
System.out.println("test_negc_n: " + (end - start));
490507

508+
start = System.currentTimeMillis();
509+
for (int i=0; i<ITERS; i++) {
510+
test_sqrt(a0, a1);
511+
}
512+
end = System.currentTimeMillis();
513+
System.out.println("test_sqrt_n: " + (end - start));
514+
491515
return errn;
492516
}
493517

@@ -579,6 +603,12 @@ static void test_negc(float[] a0, float[] a1) {
579603
}
580604
}
581605

606+
static void test_sqrt(float[] a0, float[] a1) {
607+
for (int i = 0; i < a0.length; i+=1) {
608+
a0[i] = (float)(Math.sqrt((double)a1[i]));
609+
}
610+
}
611+
582612
static int verify(String text, int i, float elem, float val) {
583613
if (elem != val && !(Float.isNaN(elem) && Float.isNaN(val))) {
584614
System.err.println(text + "[" + i + "] = " + elem + " != " + val);

0 commit comments

Comments
 (0)
This repository has been archived.