[aarch64-port-dev ] RFR(S): 8214922: Add vectorization support for fmin/fmax

Pengfei Li (Arm Technology China) Pengfei.Li at arm.com
Thu Jan 10 10:53:48 UTC 2019

Hi adinn, roland,

Sorry that I uploaded a new webrev for this today because I found that I made a mistake hidden in vectornode.cpp.

The reduction min/max ops do not correspond to the original ones correctly in below part of code.
+    case Op_MinF:
+      assert(bt == T_FLOAT, "must be");
+      vopc = Op_MinReductionV;
+      break;
+    case Op_MinD:
+      assert(bt == T_DOUBLE, "must be");
+      vopc = Op_MaxReductionV;
+      break;
+    case Op_MaxF:
+      assert(bt == T_FLOAT, "must be");
+      vopc = Op_MinReductionV;
+      break;
+    case Op_MaxD:
+      assert(bt == T_DOUBLE, "must be");
+      vopc = Op_MaxReductionV;
+      break;

I've fixed it in my 3rd webrev. So could you help review it again?

And for Andrew Dinn's question:
> Do you mean that you have not been able to exercise the reduction code at
> all? Or is it just that you cannot get it to work in a JMH test?
> Obviously, it would be better if we would provide a JMH test that does work.
> I'll see if I can provide a test.

I mean that I tried it hard and finally find one that works. As Vladimir Ivanov said the simple reduction auto-vectorization is disabled in current JDK, so we have to construct that in a more complex code shape. Below code in my previous uploaded JMH case[1] could generate the min/max reduction instructions.

      for (int i = 0; i < LENGTH; i++) {
        min = Math.min(min, fa[i] + fb[i]);

Part of disassembly outputted by JMH perfasm is like below.
0x0000ffff9cca1650: fminv    s18, v19.4s
0x0000ffff9cca1654: fmin s18, s18, s16
0x0000ffff9cca1658: fminv    s19, v20.4s
0x0000ffff9cca165c: fmin s19, s19, s18
0x0000ffff9cca1660: fminv    s16, v22.4s
0x0000ffff9cca1664: fmin s16, s16, s19
0x0000ffff9cca1668: fminv    s19, v21.4s
0x0000ffff9cca166c: fmin s19, s19, s16

[1] http://cr.openjdk.java.net/~pli/rfr/8214922/TestSIMDFpMinMax.java


More information about the hotspot-compiler-dev mailing list