[aarch64-port-dev ] RFR(S): 8243155: AArch64: Add support for SqrtVF
Yang Zhang
Yang.Zhang at arm.com
Tue Apr 28 06:57:15 UTC 2020
Hi,
Could you please help to review this patch?
JBS: https://bugs.openjdk.java.net/browse/JDK-8243155
Webrev: http://cr.openjdk.java.net/~yzhang/8243155/webrev.00/
In Java, Math.sqrt() supports double data only. To support Math.sqrt()
for float, the following conversion must be done.
float a, b;
a = (float)Math.sqrt((double)b)
Both AArch64 and x86 support such single-precision sqrt by hardware
instructions. AArch64 FSQRT instruction matches Java (float)Math.
sqrt((double)b) exactly. And X86 has supported vectorization of
Math.sqrt() on floats in [1].
In this patch, vectorized sqrt for float (SqrtVF) is supported in
AArch64 backend. Jtreg test cases for SqrtVF and SqrtVD are also
added. Special cases such as min/max, +/-Inf, +0.0/-0.0 and NaN are
covered.
Testing:
Full jtreg
Newly added sqrt jtreg tests
Panama/Vector API tests which cover vector sqrt
Test case for sqrtvf:
public static void sqrtvf(float[] a, float[] b, float[] c) {
float tmp;
for (int i = 0; i < a.length; i++) {
tmp = (float)(a[i] + b[i]);
c[i] = (float)Math.sqrt((double)tmp);
}
}
With this patch, the following code snippet is generated.
0x0000ffffacaf872c: ldr q17, [x18, #16]
0x0000ffffacaf8730: ldr q16, [x16, #16]
0x0000ffffacaf8734: fadd v16.4s, v16.4s, v17.4s
0x0000ffffacaf8738: fsqrt v16.4s, v16.4s
0x0000ffffacaf8740: str q16, [x14, #16]
Performance:
JMH test is attached in JBS.
Before:
Benchmark (size) Mode Cnt Score Error Units
TestVect.testVectSqrtVF 1024 avgt 5 4.372 ± 0.016 us/op
After:
Benchmark (size) Mode Cnt Score Error Units
TestVect.testVectSqrtVF 1024 avgt 5 1.115 ± 0.013 us/op
[1] https://bugs.openjdk.java.net/browse/JDK-8190800
Regards
Yang
More information about the hotspot-compiler-dev
mailing list