From 67d6f3ca9e8d1312c9e3a85dbe19903619f59064 Mon Sep 17 00:00:00 2001 From: Emanuel Peter Date: Tue, 4 Jun 2024 06:20:31 +0000 Subject: [PATCH] 8332905: C2 SuperWord: bad AD file, with RotateRightV and first operand not a pack Reviewed-by: chagedorn, thartmann --- src/hotspot/share/opto/superword.cpp | 2 +- .../runner/ArrayShiftOpTest.java | 22 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/opto/superword.cpp b/src/hotspot/share/opto/superword.cpp index f41e8a7b8b354..0b940a13c5481 100644 --- a/src/hotspot/share/opto/superword.cpp +++ b/src/hotspot/share/opto/superword.cpp @@ -2435,7 +2435,7 @@ bool SuperWord::output() { vn = StoreVectorNode::make(opc, ctl, mem, adr, atyp, val, vlen); vlen_in_bytes = vn->as_StoreVector()->memory_size(); } else if (VectorNode::is_scalar_rotate(n)) { - Node* in1 = first->in(1); + Node* in1 = vector_opd(p, 1); Node* in2 = first->in(2); // If rotation count is non-constant or greater than 8bit value create a vector. if (!in2->is_Con() || !Matcher::supports_vector_constant_rotates(in2->get_int())) { diff --git a/test/hotspot/jtreg/compiler/vectorization/runner/ArrayShiftOpTest.java b/test/hotspot/jtreg/compiler/vectorization/runner/ArrayShiftOpTest.java index 40307ba7e1b39..08e194db5f691 100644 --- a/test/hotspot/jtreg/compiler/vectorization/runner/ArrayShiftOpTest.java +++ b/test/hotspot/jtreg/compiler/vectorization/runner/ArrayShiftOpTest.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8183390 8332905 * @summary Vectorization test on bug-prone shift operation * @library /test/lib / * @@ -48,6 +49,7 @@ public class ArrayShiftOpTest extends VectorizationTestRunner { private static final int SIZE = 543; + private static int size = 543; private int[] ints; private long[] longs; @@ -71,7 +73,7 @@ public ArrayShiftOpTest() { } @Test - @IR(applyIfCPUFeatureOr = {"asimd", "true", "avx512f", "true"}, + @IR(applyIfCPUFeatureOr = {"asimd", "true", "avx2", "true"}, counts = {IRNode.STORE_VECTOR, ">0"}) @IR(applyIfCPUFeature = {"avx512f", "true"}, counts = {IRNode.ROTATE_RIGHT_V, ">0"}) @@ -87,7 +89,23 @@ public int[] intCombinedRotateShift() { } @Test - @IR(applyIfCPUFeatureOr = {"asimd", "true", "avx512f", "true"}, + @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"}, + counts = {IRNode.STORE_VECTOR, ">0"}) + @IR(applyIfCPUFeature = {"avx512f", "true"}, + counts = {IRNode.ROTATE_RIGHT_V, ">0"}) + // Requires size to not be known at compile time, otherwise the shift + // can get constant folded with the (iv + const) pattern from the + // PopulateIndex. + public int[] intCombinedRotateShiftWithPopulateIndex() { + int[] res = new int[size]; + for (int i = 0; i < size; i++) { + res[i] = (i << 14) | (i >>> 18); + } + return res; + } + + @Test + @IR(applyIfCPUFeatureOr = {"asimd", "true", "avx2", "true"}, counts = {IRNode.STORE_VECTOR, ">0"}) @IR(applyIfCPUFeature = {"avx512f", "true"}, counts = {IRNode.ROTATE_RIGHT_V, ">0"})