--- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/ByteScalar.java 2019-04-26 14:55:22.878066500 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/ByteScalar.java 2019-04-26 14:55:22.257265800 -0700 @@ -319,18 +319,54 @@ + @Benchmark + public void shiftLeft(Blackhole bh) { + byte[] as = fa.apply(size); + byte[] bs = fb.apply(size); + byte[] rs = fr.apply(size); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + byte a = as[i]; + byte b = bs[i]; + rs[i] = (byte)((a << (b & 0x7))); + } + } + bh.consume(rs); + } + @Benchmark + public void shiftLeftMasked(Blackhole bh) { + byte[] as = fa.apply(size); + byte[] bs = fb.apply(size); + byte[] rs = fr.apply(size); + boolean[] ms = fm.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + byte a = as[i]; + byte b = bs[i]; + if (ms[i % ms.length]) { + rs[i] = (byte)((a << (b & 0x7))); + } else { + rs[i] = a; + } + } + } + bh.consume(rs); + } + + @Benchmark - public void aShiftRShift(Blackhole bh) { + public void shiftRight(Blackhole bh) { byte[] as = fa.apply(size); byte[] bs = fb.apply(size); byte[] rs = fr.apply(size); @@ -339,7 +375,7 @@ for (int i = 0; i < as.length; i++) { byte a = as[i]; byte b = bs[i]; - rs[i] = (byte)((a >> (b & 7))); + rs[i] = (byte)((a >>> (b & 0x7))); } } @@ -349,7 +385,7 @@ @Benchmark - public void aShiftRMaskedShift(Blackhole bh) { + public void shiftRightMasked(Blackhole bh) { byte[] as = fa.apply(size); byte[] bs = fb.apply(size); byte[] rs = fr.apply(size); @@ -359,8 +395,33 @@ for (int i = 0; i < as.length; i++) { byte a = as[i]; byte b = bs[i]; - boolean m = ms[i % ms.length]; - rs[i] = (m ? (byte)((a >> (b & 7))) : a); + if (ms[i % ms.length]) { + rs[i] = (byte)((a >>> (b & 0x7))); + } else { + rs[i] = a; + } + } + } + bh.consume(rs); + } + + + + + + + + @Benchmark + public void shiftArithmeticRight(Blackhole bh) { + byte[] as = fa.apply(size); + byte[] bs = fb.apply(size); + byte[] rs = fr.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + byte a = as[i]; + byte b = bs[i]; + rs[i] = (byte)((a >> (b & 0x7))); } } @@ -370,7 +431,34 @@ @Benchmark - public void shiftLShift(Blackhole bh) { + public void shiftArithmeticRightMasked(Blackhole bh) { + byte[] as = fa.apply(size); + byte[] bs = fb.apply(size); + byte[] rs = fr.apply(size); + boolean[] ms = fm.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + byte a = as[i]; + byte b = bs[i]; + if (ms[i % ms.length]) { + rs[i] = (byte)((a >> (b & 0x7))); + } else { + rs[i] = a; + } + } + } + bh.consume(rs); + } + + + + + + + + @Benchmark + public void shiftLeftShift(Blackhole bh) { byte[] as = fa.apply(size); byte[] bs = fb.apply(size); byte[] rs = fr.apply(size); @@ -389,7 +477,7 @@ @Benchmark - public void shiftLMaskedShift(Blackhole bh) { + public void shiftLeftMaskedShift(Blackhole bh) { byte[] as = fa.apply(size); byte[] bs = fb.apply(size); byte[] rs = fr.apply(size); @@ -409,8 +497,12 @@ + + + + @Benchmark - public void shiftRShift(Blackhole bh) { + public void shiftRightShift(Blackhole bh) { byte[] as = fa.apply(size); byte[] bs = fb.apply(size); byte[] rs = fr.apply(size); @@ -429,7 +521,7 @@ @Benchmark - public void shiftRMaskedShift(Blackhole bh) { + public void shiftRightMaskedShift(Blackhole bh) { byte[] as = fa.apply(size); byte[] bs = fb.apply(size); byte[] rs = fr.apply(size); @@ -453,6 +545,46 @@ + @Benchmark + public void shiftArithmeticRightShift(Blackhole bh) { + byte[] as = fa.apply(size); + byte[] bs = fb.apply(size); + byte[] rs = fr.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + byte a = as[i]; + byte b = bs[i]; + rs[i] = (byte)((a >> (b & 7))); + } + } + + bh.consume(rs); + } + + + + @Benchmark + public void shiftArithmeticRightMaskedShift(Blackhole bh) { + byte[] as = fa.apply(size); + byte[] bs = fb.apply(size); + byte[] rs = fr.apply(size); + boolean[] ms = fm.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + byte a = as[i]; + byte b = bs[i]; + boolean m = ms[i % ms.length]; + rs[i] = (m ? (byte)((a >> (b & 7))) : a); + } + } + + bh.consume(rs); + } + + + @Benchmark public void max(Blackhole bh) { @@ -490,7 +622,7 @@ @Benchmark - public void andAll(Blackhole bh) { + public void andLanes(Blackhole bh) { byte[] as = fa.apply(size); byte r = -1; for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -505,7 +637,7 @@ @Benchmark - public void orAll(Blackhole bh) { + public void orLanes(Blackhole bh) { byte[] as = fa.apply(size); byte r = 0; for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -520,7 +652,7 @@ @Benchmark - public void xorAll(Blackhole bh) { + public void xorLanes(Blackhole bh) { byte[] as = fa.apply(size); byte r = 0; for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -534,7 +666,7 @@ @Benchmark - public void addAll(Blackhole bh) { + public void addLanes(Blackhole bh) { byte[] as = fa.apply(size); byte r = 0; for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -547,7 +679,7 @@ } @Benchmark - public void mulAll(Blackhole bh) { + public void mulLanes(Blackhole bh) { byte[] as = fa.apply(size); byte r = 1; for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -560,7 +692,7 @@ } @Benchmark - public void minAll(Blackhole bh) { + public void minLanes(Blackhole bh) { byte[] as = fa.apply(size); byte r = Byte.MAX_VALUE; for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -573,7 +705,7 @@ } @Benchmark - public void maxAll(Blackhole bh) { + public void maxLanes(Blackhole bh) { byte[] as = fa.apply(size); byte r = Byte.MIN_VALUE; for (int ic = 0; ic < INVOC_COUNT; ic++) {