Skip to content

Commit 32c0195

Browse files
committed
Remove wrong vector shuffle lowering for lasx
1 parent cfb057a commit 32c0195

File tree

3 files changed

+10
-33
lines changed

3 files changed

+10
-33
lines changed

llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,10 +1027,8 @@ static SDValue lowerVECTOR_SHUFFLE_VSHUF4I(const SDLoc &DL, ArrayRef<int> Mask,
10271027
SelectionDAG &DAG) {
10281028

10291029
unsigned SubVecSize = 4;
1030-
if (VT == MVT::v2f64 || VT == MVT::v2i64 || VT == MVT::v4f64 ||
1031-
VT == MVT::v4i64) {
1030+
if (VT == MVT::v2f64 || VT == MVT::v2i64)
10321031
SubVecSize = 2;
1033-
}
10341032

10351033
int SubMask[4] = {-1, -1, -1, -1};
10361034
for (unsigned i = 0; i < SubVecSize; ++i) {
@@ -1068,9 +1066,8 @@ static SDValue lowerVECTOR_SHUFFLE_VSHUF4I(const SDLoc &DL, ArrayRef<int> Mask,
10681066
Imm |= M & 0x3;
10691067
}
10701068

1071-
// Return vshuf4i.d and xvshuf4i.d
1072-
if (VT == MVT::v2f64 || VT == MVT::v2i64 || VT == MVT::v4f64 ||
1073-
VT == MVT::v4i64)
1069+
// Return vshuf4i.d
1070+
if (VT == MVT::v2f64 || VT == MVT::v2i64)
10741071
return DAG.getNode(LoongArchISD::VSHUF4I, DL, VT, V1, V2,
10751072
DAG.getConstant(Imm, DL, MVT::i64));
10761073

@@ -1458,6 +1455,10 @@ static SDValue lowerVECTOR_SHUFFLE_XVREPLVEI(const SDLoc &DL,
14581455
static SDValue lowerVECTOR_SHUFFLE_XVSHUF4I(const SDLoc &DL, ArrayRef<int> Mask,
14591456
MVT VT, SDValue V1, SDValue V2,
14601457
SelectionDAG &DAG) {
1458+
// When the size is less than or equal to 4, lower cost instructions may be
1459+
// used.
1460+
if (Mask.size() <= 4)
1461+
return SDValue();
14611462
return lowerVECTOR_SHUFFLE_VSHUF4I(DL, Mask, VT, V1, V2, DAG);
14621463
}
14631464

@@ -1839,9 +1840,6 @@ static SDValue lower256BitShuffle(const SDLoc &DL, ArrayRef<int> Mask, MVT VT,
18391840
return Result;
18401841
if ((Result = lowerVECTOR_SHUFFLE_XVPICKOD(DL, NewMask, VT, V1, V2, DAG)))
18411842
return Result;
1842-
if ((VT.SimpleTy == MVT::v4i64 || VT.SimpleTy == MVT::v4f64) &&
1843-
(Result = lowerVECTOR_SHUFFLE_XVSHUF4I(DL, NewMask, VT, V1, V2, DAG)))
1844-
return Result;
18451843
if ((Result =
18461844
lowerVECTOR_SHUFFLEAsShift(DL, NewMask, VT, V1, V2, DAG, Zeroable)))
18471845
return Result;

llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def SDT_LoongArchV2R : SDTypeProfile<1, 2, [SDTCisVec<0>,
2323
SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>]>;
2424
def SDT_LoongArchV1RUimm: SDTypeProfile<1, 2, [SDTCisVec<0>,
2525
SDTCisSameAs<0,1>, SDTCisVT<2, i64>]>;
26-
def SDT_LoongArchVShuf4i_D
26+
def SDT_LoongArchV2RUimm
2727
: SDTypeProfile<1, 3,
2828
[SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
2929
SDTCisVT<3, i64>]>;
@@ -57,8 +57,7 @@ def loongarch_vilvl: SDNode<"LoongArchISD::VILVL", SDT_LoongArchV2R>;
5757
def loongarch_vilvh: SDNode<"LoongArchISD::VILVH", SDT_LoongArchV2R>;
5858

5959
def loongarch_vshuf4i: SDNode<"LoongArchISD::VSHUF4I", SDT_LoongArchV1RUimm>;
60-
def loongarch_vshuf4i_d
61-
: SDNode<"LoongArchISD::VSHUF4I", SDT_LoongArchVShuf4i_D>;
60+
def loongarch_vshuf4i_d : SDNode<"LoongArchISD::VSHUF4I", SDT_LoongArchV2RUimm>;
6261
def loongarch_vreplvei: SDNode<"LoongArchISD::VREPLVEI", SDT_LoongArchV1RUimm>;
6362
def loongarch_vreplgr2vr: SDNode<"LoongArchISD::VREPLGR2VR", SDT_LoongArchVreplgr2vr>;
6463

llvm/test/CodeGen/LoongArch/lasx/ir-instruction/shuffle-as-xvshuf4i.ll

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,4 @@ define <8 x float> @shufflevector_xvshuf4i_v8f32(<8 x float> %a, <8 x float> %b)
4040
; CHECK-NEXT: ret
4141
%c = shufflevector <8 x float> %a, <8 x float> %b, <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
4242
ret <8 x float> %c
43-
}
44-
45-
;; xvshuf4i.d
46-
define <4 x i64> @shufflevector_xvshuf4i_v4d64(<4 x i64> %a, <4 x i64> %b) {
47-
; CHECK-LABEL: shufflevector_xvshuf4i_v4d64:
48-
; CHECK: # %bb.0:
49-
; CHECK-NEXT: xvshuf4i.d $xr0, $xr1, 9
50-
; CHECK-NEXT: ret
51-
%c = shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32> <i32 1, i32 2, i32 5, i32 6>
52-
ret <4 x i64> %c
53-
}
54-
55-
;; xvshuf4i.d
56-
define <4 x double> @shufflevector_xvshuf4i_v4f64(<4 x double> %a, <4 x double> %b) {
57-
; CHECK-LABEL: shufflevector_xvshuf4i_v4f64:
58-
; CHECK: # %bb.0:
59-
; CHECK-NEXT: xvshuf4i.d $xr0, $xr1, 9
60-
; CHECK-NEXT: ret
61-
%c = shufflevector <4 x double> %a, <4 x double> %b, <4 x i32> <i32 1, i32 2, i32 5, i32 6>
62-
ret <4 x double> %c
63-
}
43+
}

0 commit comments

Comments
 (0)