Skip to content

Commit a6a5507

Browse files
committed
Revert "[RISCV] Allow undef prefix for local repeating VLA shuffle lowering (#126097)"
This reverts commit ab0006d. It appears to have rebased badly during web merge.
1 parent 022c9c9 commit a6a5507

File tree

2 files changed

+15
-51
lines changed

2 files changed

+15
-51
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

+7-10
Original file line numberDiff line numberDiff line change
@@ -5338,17 +5338,13 @@ static SDValue lowerDisjointIndicesShuffle(ShuffleVectorSDNode *SVN,
53385338
/// Is this mask local (i.e. elements only move within their local span), and
53395339
/// repeating (that is, the same rearrangement is being done within each span)?
53405340
static bool isLocalRepeatingShuffle(ArrayRef<int> Mask, int Span) {
5341-
SmallVector<int> LowSpan(Span, -1);
5341+
// TODO: Could improve the case where undef elements exist in the first span.
53425342
for (auto [I, M] : enumerate(Mask)) {
53435343
if (M == -1)
53445344
continue;
5345-
if ((M / Span) != (int)(I / Span))
5346-
return false;
5347-
int SpanIdx = I % Span;
5348-
int Expected = M % Span;
5349-
if (LowSpan[SpanIdx] == -1)
5350-
LowSpan[SpanIdx] = Expected;
5351-
if (LowSpan[SpanIdx] != Expected)
5345+
int ChunkLo = I - (I % Span);
5346+
int ChunkHi = ChunkLo + Span;
5347+
if (M < ChunkLo || M >= ChunkHi || M - ChunkLo != Mask[I % Span])
53525348
return false;
53535349
}
53545350
return true;
@@ -5752,8 +5748,9 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
57525748
// If we have a locally repeating mask, then we can reuse the first register
57535749
// in the index register group for all registers within the source register
57545750
// group. TODO: This generalizes to m2, and m4.
5755-
if (NumElts > MinVLMAX && isLocalRepeatingShuffle(Mask, MinVLMAX)) {
5756-
const MVT M1VT = getLMUL1VT(ContainerVT);
5751+
const MVT M1VT = getLMUL1VT(ContainerVT);
5752+
auto VLMAX = RISCVTargetLowering::computeVLMAXBounds(M1VT, Subtarget).first;
5753+
if (ContainerVT.bitsGT(M1VT) && isLocalRepeatingShuffle(Mask, VLMAX)) {
57575754
EVT SubIndexVT = M1VT.changeVectorElementType(IndexVT.getScalarType());
57585755
SDValue SubIndex =
57595756
DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, SubIndexVT, LHSIndices,

llvm/test/CodeGen/RISCV/rvv/fixed-vectors-shuffle-rotate.ll

+8-41
Original file line numberDiff line numberDiff line change
@@ -969,44 +969,11 @@ define <8 x i64> @shuffle_v8i64_as_i128(<8 x i64> %v) {
969969
ret <8 x i64> %shuffle
970970
}
971971

972-
; Test case where first span has undefs
973-
define <8 x i64> @shuffle_v8i64_as_i128_2(<8 x i64> %v) {
974-
; CHECK-LABEL: shuffle_v8i64_as_i128_2:
975-
; CHECK: # %bb.0:
976-
; CHECK-NEXT: lui a0, %hi(.LCPI30_0)
977-
; CHECK-NEXT: addi a0, a0, %lo(.LCPI30_0)
978-
; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
979-
; CHECK-NEXT: vle16.v v16, (a0)
980-
; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
981-
; CHECK-NEXT: vrgatherei16.vv v13, v9, v16
982-
; CHECK-NEXT: vrgatherei16.vv v12, v8, v16
983-
; CHECK-NEXT: vrgatherei16.vv v14, v10, v16
984-
; CHECK-NEXT: vrgatherei16.vv v15, v11, v16
985-
; CHECK-NEXT: vmv4r.v v8, v12
986-
; CHECK-NEXT: ret
987-
;
988-
; ZVKB-V-LABEL: shuffle_v8i64_as_i128_2:
989-
; ZVKB-V: # %bb.0:
990-
; ZVKB-V-NEXT: lui a0, %hi(.LCPI30_0)
991-
; ZVKB-V-NEXT: addi a0, a0, %lo(.LCPI30_0)
992-
; ZVKB-V-NEXT: vsetivli zero, 8, e16, m1, ta, ma
993-
; ZVKB-V-NEXT: vle16.v v16, (a0)
994-
; ZVKB-V-NEXT: vsetvli a0, zero, e64, m1, ta, ma
995-
; ZVKB-V-NEXT: vrgatherei16.vv v13, v9, v16
996-
; ZVKB-V-NEXT: vrgatherei16.vv v12, v8, v16
997-
; ZVKB-V-NEXT: vrgatherei16.vv v14, v10, v16
998-
; ZVKB-V-NEXT: vrgatherei16.vv v15, v11, v16
999-
; ZVKB-V-NEXT: vmv4r.v v8, v12
1000-
; ZVKB-V-NEXT: ret
1001-
%shuffle = shufflevector <8 x i64> %v, <8 x i64> poison, <8 x i32> <i32 undef, i32 undef, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6>
1002-
ret <8 x i64> %shuffle
1003-
}
1004-
1005972
define <8 x i64> @shuffle_v8i64_as_i256(<8 x i64> %v) {
1006973
; CHECK-LABEL: shuffle_v8i64_as_i256:
1007974
; CHECK: # %bb.0:
1008-
; CHECK-NEXT: lui a0, %hi(.LCPI31_0)
1009-
; CHECK-NEXT: addi a0, a0, %lo(.LCPI31_0)
975+
; CHECK-NEXT: lui a0, %hi(.LCPI30_0)
976+
; CHECK-NEXT: addi a0, a0, %lo(.LCPI30_0)
1010977
; CHECK-NEXT: vsetivli zero, 8, e64, m4, ta, ma
1011978
; CHECK-NEXT: vle16.v v16, (a0)
1012979
; CHECK-NEXT: vrgatherei16.vv v12, v8, v16
@@ -1015,8 +982,8 @@ define <8 x i64> @shuffle_v8i64_as_i256(<8 x i64> %v) {
1015982
;
1016983
; ZVKB-V-LABEL: shuffle_v8i64_as_i256:
1017984
; ZVKB-V: # %bb.0:
1018-
; ZVKB-V-NEXT: lui a0, %hi(.LCPI31_0)
1019-
; ZVKB-V-NEXT: addi a0, a0, %lo(.LCPI31_0)
985+
; ZVKB-V-NEXT: lui a0, %hi(.LCPI30_0)
986+
; ZVKB-V-NEXT: addi a0, a0, %lo(.LCPI30_0)
1020987
; ZVKB-V-NEXT: vsetivli zero, 8, e64, m4, ta, ma
1021988
; ZVKB-V-NEXT: vle16.v v16, (a0)
1022989
; ZVKB-V-NEXT: vrgatherei16.vv v12, v8, v16
@@ -1029,8 +996,8 @@ define <8 x i64> @shuffle_v8i64_as_i256(<8 x i64> %v) {
1029996
define <8 x i64> @shuffle_v8i64_as_i256_zvl256b(<8 x i64> %v) vscale_range(4,0) {
1030997
; CHECK-LABEL: shuffle_v8i64_as_i256_zvl256b:
1031998
; CHECK: # %bb.0:
1032-
; CHECK-NEXT: lui a0, %hi(.LCPI32_0)
1033-
; CHECK-NEXT: addi a0, a0, %lo(.LCPI32_0)
999+
; CHECK-NEXT: lui a0, %hi(.LCPI31_0)
1000+
; CHECK-NEXT: addi a0, a0, %lo(.LCPI31_0)
10341001
; CHECK-NEXT: vsetivli zero, 8, e16, mf2, ta, ma
10351002
; CHECK-NEXT: vle16.v v12, (a0)
10361003
; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
@@ -1041,8 +1008,8 @@ define <8 x i64> @shuffle_v8i64_as_i256_zvl256b(<8 x i64> %v) vscale_range(4,0)
10411008
;
10421009
; ZVKB-V-LABEL: shuffle_v8i64_as_i256_zvl256b:
10431010
; ZVKB-V: # %bb.0:
1044-
; ZVKB-V-NEXT: lui a0, %hi(.LCPI32_0)
1045-
; ZVKB-V-NEXT: addi a0, a0, %lo(.LCPI32_0)
1011+
; ZVKB-V-NEXT: lui a0, %hi(.LCPI31_0)
1012+
; ZVKB-V-NEXT: addi a0, a0, %lo(.LCPI31_0)
10461013
; ZVKB-V-NEXT: vsetivli zero, 8, e16, mf2, ta, ma
10471014
; ZVKB-V-NEXT: vle16.v v12, (a0)
10481015
; ZVKB-V-NEXT: vsetvli a0, zero, e64, m1, ta, ma

0 commit comments

Comments
 (0)