changeset 58249:a1aacba7b7b2 vectorIntrinsics

Clean up variable shifts and intOrLong flag Two changes contained in this patch: - intOrlong has been renamed to be consistent with others. It is now intOrLong. This led to a place where it was intended to be used to correctly generate now. - variable shifts are only supported for int and long. This was added from a recommendation on panama but initial discussion and plan was specifically specified only for int and long.
author rlupusoru
date Thu, 05 Apr 2018 11:00:13 -0700
parents 014bddccfd0d
children 5d0584f62708
files src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorHelper.java.template src/jdk.incubator.vector/share/classes/jdk/incubator/vector/gen-src.sh
diffstat 8 files changed, 89 insertions(+), 125 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java	Thu Apr 05 06:30:13 2018 -0700
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java	Thu Apr 05 11:00:13 2018 -0700
@@ -334,56 +334,35 @@
     }
 
     // logical shift left
-    public ByteVector<S> shiftL(Vector<Byte,S> o) {
-        return bOp(o, (i, a, b) -> (byte) (a << b));
-    }
-
     public ByteVector<S> shiftL(int s) {
         return uOp((i, a) -> (byte) (a << s));
     }
 
-    public ByteVector<S> shiftL(Vector<Byte,S> o, Mask<Byte, S> m) {
-        return bOp(o, m, (i, a, b) -> (byte) (a << b));
-    }
-
     public ByteVector<S> shiftL(int s, Mask<Byte, S> m) {
         return uOp(m, (i, a) -> (byte) (a << s));
     }
 
+
     // logical, or unsigned, shift right
-    public ByteVector<S> shiftR(Vector<Byte,S> o) {
-        return bOp(o, (i, a, b) -> (byte) (a >>> b));
-    }
-
     public ByteVector<S> shiftR(int s) {
         return uOp((i, a) -> (byte) (a >>> s));
     }
 
-    public ByteVector<S> shiftR(Vector<Byte,S> o, Mask<Byte, S> m) {
-        return bOp(o, m, (i, a, b) -> (byte) (a >>> b));
-    }
-
     public ByteVector<S> shiftR(int s, Mask<Byte, S> m) {
         return uOp(m, (i, a) -> (byte) (a >>> s));
     }
 
+
     // arithmetic, or signed, shift right
-    public ByteVector<S> ashiftR(Vector<Byte,S> o) {
-        return bOp(o, (i, a, b) -> (byte) (a >> b));
-    }
-
     public ByteVector<S> aShiftR(int s) {
         return uOp((i, a) -> (byte) (a >> s));
     }
 
-    public ByteVector<S> ashiftR(Vector<Byte,S> o, Mask<Byte, S> m) {
-        return bOp(o, m, (i, a, b) -> (byte) (a >> b));
-    }
-
     public ByteVector<S> aShiftR(int s, Mask<Byte, S> m) {
         return uOp(m, (i, a) -> (byte) (a >> s));
     }
 
+
     public ByteVector<S> rotateL(int j) {
         return uOp((i, a) -> (byte) Integer.rotateLeft(a, j));
     }
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java	Thu Apr 05 06:30:13 2018 -0700
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java	Thu Apr 05 11:00:13 2018 -0700
@@ -335,56 +335,56 @@
     }
 
     // logical shift left
+    public IntVector<S> shiftL(int s) {
+        return uOp((i, a) -> (int) (a << s));
+    }
+
+    public IntVector<S> shiftL(int s, Mask<Integer, S> m) {
+        return uOp(m, (i, a) -> (int) (a << s));
+    }
+
     public IntVector<S> shiftL(Vector<Integer,S> o) {
         return bOp(o, (i, a, b) -> (int) (a << b));
     }
 
-    public IntVector<S> shiftL(int s) {
-        return uOp((i, a) -> (int) (a << s));
-    }
-
     public IntVector<S> shiftL(Vector<Integer,S> o, Mask<Integer, S> m) {
         return bOp(o, m, (i, a, b) -> (int) (a << b));
     }
 
-    public IntVector<S> shiftL(int s, Mask<Integer, S> m) {
-        return uOp(m, (i, a) -> (int) (a << s));
+    // logical, or unsigned, shift right
+    public IntVector<S> shiftR(int s) {
+        return uOp((i, a) -> (int) (a >>> s));
     }
 
-    // logical, or unsigned, shift right
+    public IntVector<S> shiftR(int s, Mask<Integer, S> m) {
+        return uOp(m, (i, a) -> (int) (a >>> s));
+    }
+
     public IntVector<S> shiftR(Vector<Integer,S> o) {
         return bOp(o, (i, a, b) -> (int) (a >>> b));
     }
 
-    public IntVector<S> shiftR(int s) {
-        return uOp((i, a) -> (int) (a >>> s));
-    }
-
     public IntVector<S> shiftR(Vector<Integer,S> o, Mask<Integer, S> m) {
         return bOp(o, m, (i, a, b) -> (int) (a >>> b));
     }
 
-    public IntVector<S> shiftR(int s, Mask<Integer, S> m) {
-        return uOp(m, (i, a) -> (int) (a >>> s));
+    // arithmetic, or signed, shift right
+    public IntVector<S> aShiftR(int s) {
+        return uOp((i, a) -> (int) (a >> s));
     }
 
-    // arithmetic, or signed, shift right
+    public IntVector<S> aShiftR(int s, Mask<Integer, S> m) {
+        return uOp(m, (i, a) -> (int) (a >> s));
+    }
+
     public IntVector<S> ashiftR(Vector<Integer,S> o) {
         return bOp(o, (i, a, b) -> (int) (a >> b));
     }
 
-    public IntVector<S> aShiftR(int s) {
-        return uOp((i, a) -> (int) (a >> s));
-    }
-
     public IntVector<S> ashiftR(Vector<Integer,S> o, Mask<Integer, S> m) {
         return bOp(o, m, (i, a, b) -> (int) (a >> b));
     }
 
-    public IntVector<S> aShiftR(int s, Mask<Integer, S> m) {
-        return uOp(m, (i, a) -> (int) (a >> s));
-    }
-
     public IntVector<S> rotateL(int j) {
         return uOp((i, a) -> (int) Integer.rotateLeft(a, j));
     }
@@ -560,7 +560,7 @@
 
         public IntVector<S> random() {
             ThreadLocalRandom r = ThreadLocalRandom.current();
-            return op(i -> (int) r.nextInt());
+            return op(i -> r.nextInt());
         }
 
         public IntVector<S> scalars(int... es) {
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java	Thu Apr 05 06:30:13 2018 -0700
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java	Thu Apr 05 11:00:13 2018 -0700
@@ -335,56 +335,56 @@
     }
 
     // logical shift left
+    public LongVector<S> shiftL(int s) {
+        return uOp((i, a) -> (long) (a << s));
+    }
+
+    public LongVector<S> shiftL(int s, Mask<Long, S> m) {
+        return uOp(m, (i, a) -> (long) (a << s));
+    }
+
     public LongVector<S> shiftL(Vector<Long,S> o) {
         return bOp(o, (i, a, b) -> (long) (a << b));
     }
 
-    public LongVector<S> shiftL(int s) {
-        return uOp((i, a) -> (long) (a << s));
-    }
-
     public LongVector<S> shiftL(Vector<Long,S> o, Mask<Long, S> m) {
         return bOp(o, m, (i, a, b) -> (long) (a << b));
     }
 
-    public LongVector<S> shiftL(int s, Mask<Long, S> m) {
-        return uOp(m, (i, a) -> (long) (a << s));
+    // logical, or unsigned, shift right
+    public LongVector<S> shiftR(int s) {
+        return uOp((i, a) -> (long) (a >>> s));
     }
 
-    // logical, or unsigned, shift right
+    public LongVector<S> shiftR(int s, Mask<Long, S> m) {
+        return uOp(m, (i, a) -> (long) (a >>> s));
+    }
+
     public LongVector<S> shiftR(Vector<Long,S> o) {
         return bOp(o, (i, a, b) -> (long) (a >>> b));
     }
 
-    public LongVector<S> shiftR(int s) {
-        return uOp((i, a) -> (long) (a >>> s));
-    }
-
     public LongVector<S> shiftR(Vector<Long,S> o, Mask<Long, S> m) {
         return bOp(o, m, (i, a, b) -> (long) (a >>> b));
     }
 
-    public LongVector<S> shiftR(int s, Mask<Long, S> m) {
-        return uOp(m, (i, a) -> (long) (a >>> s));
+    // arithmetic, or signed, shift right
+    public LongVector<S> aShiftR(int s) {
+        return uOp((i, a) -> (long) (a >> s));
     }
 
-    // arithmetic, or signed, shift right
+    public LongVector<S> aShiftR(int s, Mask<Long, S> m) {
+        return uOp(m, (i, a) -> (long) (a >> s));
+    }
+
     public LongVector<S> ashiftR(Vector<Long,S> o) {
         return bOp(o, (i, a, b) -> (long) (a >> b));
     }
 
-    public LongVector<S> aShiftR(int s) {
-        return uOp((i, a) -> (long) (a >> s));
-    }
-
     public LongVector<S> ashiftR(Vector<Long,S> o, Mask<Long, S> m) {
         return bOp(o, m, (i, a, b) -> (long) (a >> b));
     }
 
-    public LongVector<S> aShiftR(int s, Mask<Long, S> m) {
-        return uOp(m, (i, a) -> (long) (a >> s));
-    }
-
     public LongVector<S> rotateL(int j) {
         return uOp((i, a) -> (long) Long.rotateLeft(a, j));
     }
@@ -560,7 +560,7 @@
 
         public LongVector<S> random() {
             ThreadLocalRandom r = ThreadLocalRandom.current();
-            return op(i -> (long) r.nextInt());
+            return op(i -> r.nextLong());
         }
 
         public LongVector<S> scalars(long... es) {
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java	Thu Apr 05 06:30:13 2018 -0700
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java	Thu Apr 05 11:00:13 2018 -0700
@@ -335,56 +335,35 @@
     }
 
     // logical shift left
-    public ShortVector<S> shiftL(Vector<Short,S> o) {
-        return bOp(o, (i, a, b) -> (short) (a << b));
-    }
-
     public ShortVector<S> shiftL(int s) {
         return uOp((i, a) -> (short) (a << s));
     }
 
-    public ShortVector<S> shiftL(Vector<Short,S> o, Mask<Short, S> m) {
-        return bOp(o, m, (i, a, b) -> (short) (a << b));
-    }
-
     public ShortVector<S> shiftL(int s, Mask<Short, S> m) {
         return uOp(m, (i, a) -> (short) (a << s));
     }
 
+
     // logical, or unsigned, shift right
-    public ShortVector<S> shiftR(Vector<Short,S> o) {
-        return bOp(o, (i, a, b) -> (short) (a >>> b));
-    }
-
     public ShortVector<S> shiftR(int s) {
         return uOp((i, a) -> (short) (a >>> s));
     }
 
-    public ShortVector<S> shiftR(Vector<Short,S> o, Mask<Short, S> m) {
-        return bOp(o, m, (i, a, b) -> (short) (a >>> b));
-    }
-
     public ShortVector<S> shiftR(int s, Mask<Short, S> m) {
         return uOp(m, (i, a) -> (short) (a >>> s));
     }
 
+
     // arithmetic, or signed, shift right
-    public ShortVector<S> ashiftR(Vector<Short,S> o) {
-        return bOp(o, (i, a, b) -> (short) (a >> b));
-    }
-
     public ShortVector<S> aShiftR(int s) {
         return uOp((i, a) -> (short) (a >> s));
     }
 
-    public ShortVector<S> ashiftR(Vector<Short,S> o, Mask<Short, S> m) {
-        return bOp(o, m, (i, a, b) -> (short) (a >> b));
-    }
-
     public ShortVector<S> aShiftR(int s, Mask<Short, S> m) {
         return uOp(m, (i, a) -> (short) (a >> s));
     }
 
+
     public ShortVector<S> rotateL(int j) {
         return uOp((i, a) -> (short) Integer.rotateLeft(a, j));
     }
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template	Thu Apr 05 06:30:13 2018 -0700
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template	Thu Apr 05 11:00:13 2018 -0700
@@ -527,55 +527,61 @@
     }
 
     // logical shift left
-    public $abstractvectortype$<S> shiftL(Vector<$Boxtype$,S> o) {
-        return bOp(o, (i, a, b) -> ($type$) (a << b));
-    }
-
     public $abstractvectortype$<S> shiftL(int s) {
         return uOp((i, a) -> ($type$) (a << s));
     }
 
-    public $abstractvectortype$<S> shiftL(Vector<$Boxtype$,S> o, Mask<$Boxtype$, S> m) {
-        return bOp(o, m, (i, a, b) -> ($type$) (a << b));
-    }
-
     public $abstractvectortype$<S> shiftL(int s, Mask<$Boxtype$, S> m) {
         return uOp(m, (i, a) -> ($type$) (a << s));
     }
 
-    // logical, or unsigned, shift right
-    public $abstractvectortype$<S> shiftR(Vector<$Boxtype$,S> o) {
-        return bOp(o, (i, a, b) -> ($type$) (a >>> b));
+#if[intOrLong]
+    public $abstractvectortype$<S> shiftL(Vector<$Boxtype$,S> o) {
+        return bOp(o, (i, a, b) -> ($type$) (a << b));
     }
 
+    public $abstractvectortype$<S> shiftL(Vector<$Boxtype$,S> o, Mask<$Boxtype$, S> m) {
+        return bOp(o, m, (i, a, b) -> ($type$) (a << b));
+    }
+#end[intOrLong]
+
+    // logical, or unsigned, shift right
     public $abstractvectortype$<S> shiftR(int s) {
         return uOp((i, a) -> ($type$) (a >>> s));
     }
 
-    public $abstractvectortype$<S> shiftR(Vector<$Boxtype$,S> o, Mask<$Boxtype$, S> m) {
-        return bOp(o, m, (i, a, b) -> ($type$) (a >>> b));
-    }
-
     public $abstractvectortype$<S> shiftR(int s, Mask<$Boxtype$, S> m) {
         return uOp(m, (i, a) -> ($type$) (a >>> s));
     }
 
+#if[intOrLong]
+    public $abstractvectortype$<S> shiftR(Vector<$Boxtype$,S> o) {
+        return bOp(o, (i, a, b) -> ($type$) (a >>> b));
+    }
+
+    public $abstractvectortype$<S> shiftR(Vector<$Boxtype$,S> o, Mask<$Boxtype$, S> m) {
+        return bOp(o, m, (i, a, b) -> ($type$) (a >>> b));
+    }
+#end[intOrLong]
+
     // arithmetic, or signed, shift right
+    public $abstractvectortype$<S> aShiftR(int s) {
+        return uOp((i, a) -> ($type$) (a >> s));
+    }
+
+    public $abstractvectortype$<S> aShiftR(int s, Mask<$Boxtype$, S> m) {
+        return uOp(m, (i, a) -> ($type$) (a >> s));
+    }
+
+#if[intOrLong]
     public $abstractvectortype$<S> ashiftR(Vector<$Boxtype$,S> o) {
         return bOp(o, (i, a, b) -> ($type$) (a >> b));
     }
 
-    public $abstractvectortype$<S> aShiftR(int s) {
-        return uOp((i, a) -> ($type$) (a >> s));
-    }
-
     public $abstractvectortype$<S> ashiftR(Vector<$Boxtype$,S> o, Mask<$Boxtype$, S> m) {
         return bOp(o, m, (i, a, b) -> ($type$) (a >> b));
     }
-
-    public $abstractvectortype$<S> aShiftR(int s, Mask<$Boxtype$, S> m) {
-        return uOp(m, (i, a) -> ($type$) (a >> s));
-    }
+#end[intOrLong]
 
     public $abstractvectortype$<S> rotateL(int j) {
         return uOp((i, a) -> ($type$) $Wideboxtype$.rotateLeft(a, j));
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template	Thu Apr 05 06:30:13 2018 -0700
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template	Thu Apr 05 11:00:13 2018 -0700
@@ -576,7 +576,7 @@
 
     // Type specific horizontal reductions
 
-#if[intOrlong]
+#if[intOrLong]
     @Override
     @ForceInline
     public $type$ addAll() {
@@ -630,7 +630,7 @@
             this,
             v -> (long) v.rOp(($type$) 0, (i, a, b) -> ($type$) (a - b)));
     }
-#end[intOrlong]
+#end[intOrLong]
 #if[FP]
     @Override
     @ForceInline
@@ -817,7 +817,7 @@
     }
 #end[FP]
 
-#if[intOrlong]
+#if[intOrLong]
     $fpvectortype$ toFP() {
         $type$[] vec = getElements();
         $fptype$[] res = new $fptype$[this.species().length()];
@@ -826,7 +826,7 @@
         }
         return new $fpvectortype$(res);
     }
-#end[intOrlong]
+#end[intOrLong]
 
     @Override
     public $vectortype$ rotateEL(int j) {
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorHelper.java.template	Thu Apr 05 06:30:13 2018 -0700
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorHelper.java.template	Thu Apr 05 11:00:13 2018 -0700
@@ -82,7 +82,7 @@
     }
 #end[BITWISE]
 
-#if[intOrlong]
+#if[intOrLong]
     public static <S extends Vector.Shape>
     $abstractvectortype$<S> addExact($abstractvectortype$<S> va, $abstractvectortype$<S> vb) {
         return va.bOp(vb, (i, a, b) -> Math.addExact(a, b));
@@ -142,7 +142,7 @@
     $abstractvectortype$<S> subtractExtract($abstractvectortype$<S> va, $abstractvectortype$<S> vb, Vector.Mask<$Boxtype$,S> m) {
         return va.bOp(vb, m, (i, a, b) -> Math.subtractExact(a, b));
     }
-#end[intOrlong]
+#end[intOrLong]
 #if[int]
     // @@@ Shape specific
     // Int256Vector -> Long512Vector
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/gen-src.sh	Thu Apr 05 06:30:13 2018 -0700
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/gen-src.sh	Thu Apr 05 11:00:13 2018 -0700
@@ -38,13 +38,13 @@
       fptype=float
       Fptype=Float
       Boxfptype=Float
-      args="$args -KintOrlong -KintOrFP -KintOrFloat"
+      args="$args -KintOrLong -KintOrFP -KintOrFloat"
       ;;
     long)
       fptype=double
       Fptype=Double
       Boxfptype=Double
-      args="$args -KintOrlong"
+      args="$args -KintOrLong"
       ;;
     float)
       kind=FP