[aarch64-port-dev ] [16] RFR(S): 8251525: AARCH64: Faster Math.signum(fp)

Andrew Haley aph at redhat.com
Sat Aug 15 13:50:42 UTC 2020


I've been looking at the way Math.signum() is used, mostly by
searching the GitHub code database. I've changed the JMH test to be
IMO more realistic: it's at
http://cr.openjdk.java.net/~aph/DoubleSignum.java. I think it's more
realitic because signum() results usually aren't stored but are used
to feed other arithmetic ops, usually + or *.

Baseline:

Benchmark                  Mode  Cnt  Score   Error  Units
DoubleSignum.ofMostlyNaN   avgt    3  2.409 ± 0.051  ns/op
DoubleSignum.ofMostlyNeg   avgt    3  2.475 ± 0.211  ns/op
DoubleSignum.ofMostlyPos   avgt    3  2.494 ± 0.015  ns/op
DoubleSignum.ofMostlyZero  avgt    3  2.501 ± 0.008  ns/op
DoubleSignum.ofRandom      avgt    3  2.458 ± 0.373  ns/op
DoubleSignum.overhead      avgt    3  2.373 ± 0.029  ns/op

-XX:+UseSignumIntrinsic:

Benchmark                  Mode  Cnt  Score   Error  Units
DoubleSignum.ofMostlyNaN   avgt    3  2.776 ± 0.006  ns/op
DoubleSignum.ofMostlyNeg   avgt    3  2.773 ± 0.066  ns/op
DoubleSignum.ofMostlyPos   avgt    3  2.772 ± 0.084  ns/op
DoubleSignum.ofMostlyZero  avgt    3  2.770 ± 0.045  ns/op
DoubleSignum.ofRandom      avgt    3  2.769 ± 0.005  ns/op
DoubleSignum.overhead      avgt    3  2.376 ± 0.013  ns/op


I think it might be more useful for you to work on optimizing
Math.copysign().

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



More information about the hotspot-compiler-dev mailing list