Skip to content

Commit ee3de56

Browse files
committed
reorder the lower shuffle opertation
1 parent 95b21e1 commit ee3de56

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp

+6-10
Original file line numberDiff line numberDiff line change
@@ -1351,11 +1351,6 @@ static SDValue lower128BitShuffle(const SDLoc &DL, ArrayRef<int> Mask, MVT VT,
13511351
/* V2 = V1; */
13521352
}
13531353

1354-
if (VT.SimpleTy == MVT::v2i64 || VT.SimpleTy == MVT::v2f64) {
1355-
if ((Result = lowerVECTOR_SHUFFLE_VSHUF4I(DL, Mask, VT, V1, V2, DAG)))
1356-
return Result;
1357-
}
1358-
13591354
// It is recommended not to change the pattern comparison order for better
13601355
// performance.
13611356
if ((Result = lowerVECTOR_SHUFFLE_VPACKEV(DL, Mask, VT, V1, V2, DAG)))
@@ -1370,6 +1365,9 @@ static SDValue lower128BitShuffle(const SDLoc &DL, ArrayRef<int> Mask, MVT VT,
13701365
return Result;
13711366
if ((Result = lowerVECTOR_SHUFFLE_VPICKOD(DL, Mask, VT, V1, V2, DAG)))
13721367
return Result;
1368+
if ((VT.SimpleTy == MVT::v2i64 || VT.SimpleTy == MVT::v2f64) &&
1369+
(Result = lowerVECTOR_SHUFFLE_VSHUF4I(DL, Mask, VT, V1, V2, DAG)))
1370+
return Result;
13731371
if ((Result = lowerVECTOR_SHUFFLEAsZeroOrAnyExtend(DL, Mask, VT, V1, V2, DAG,
13741372
Zeroable)))
13751373
return Result;
@@ -1793,11 +1791,6 @@ static SDValue lower256BitShuffle(const SDLoc &DL, ArrayRef<int> Mask, MVT VT,
17931791
/* V2 = V1; */
17941792
}
17951793

1796-
if (VT.SimpleTy == MVT::v4i64 || VT.SimpleTy == MVT::v4f64) {
1797-
if ((Result = lowerVECTOR_SHUFFLE_XVSHUF4I(DL, NewMask, VT, V1, V2, DAG)))
1798-
return Result;
1799-
}
1800-
18011794
// It is recommended not to change the pattern comparison order for better
18021795
// performance.
18031796
if ((Result = lowerVECTOR_SHUFFLE_XVPACKEV(DL, NewMask, VT, V1, V2, DAG)))
@@ -1812,6 +1805,9 @@ static SDValue lower256BitShuffle(const SDLoc &DL, ArrayRef<int> Mask, MVT VT,
18121805
return Result;
18131806
if ((Result = lowerVECTOR_SHUFFLE_XVPICKOD(DL, NewMask, VT, V1, V2, DAG)))
18141807
return Result;
1808+
if ((VT.SimpleTy == MVT::v4i64 || VT.SimpleTy == MVT::v4f64) &&
1809+
(Result = lowerVECTOR_SHUFFLE_XVSHUF4I(DL, NewMask, VT, V1, V2, DAG)))
1810+
return Result;
18151811
if ((Result =
18161812
lowerVECTOR_SHUFFLEAsShift(DL, NewMask, VT, V1, V2, DAG, Zeroable)))
18171813
return Result;

llvm/test/CodeGen/LoongArch/lsx/ir-instruction/shuffle-as-vpack.ll

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ define <4 x i32> @shufflevector_pack_ev_v4i32(<4 x i32> %a, <4 x i32> %b) {
3535
define <2 x i64> @shufflevector_pack_ev_v2i64(<2 x i64> %a, <2 x i64> %b) {
3636
; CHECK-LABEL: shufflevector_pack_ev_v2i64:
3737
; CHECK: # %bb.0:
38-
; CHECK-NEXT: vshuf4i.d $vr0, $vr1, 8
38+
; CHECK-NEXT: vpackev.d $vr0, $vr1, $vr0
3939
; CHECK-NEXT: ret
4040
%c = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 0, i32 2>
4141
ret <2 x i64> %c
@@ -55,7 +55,7 @@ define <4 x float> @shufflevector_pack_ev_v4f32(<4 x float> %a, <4 x float> %b)
5555
define <2 x double> @shufflevector_pack_ev_v2f64(<2 x double> %a, <2 x double> %b) {
5656
; CHECK-LABEL: shufflevector_pack_ev_v2f64:
5757
; CHECK: # %bb.0:
58-
; CHECK-NEXT: vshuf4i.d $vr0, $vr1, 8
58+
; CHECK-NEXT: vpackev.d $vr0, $vr1, $vr0
5959
; CHECK-NEXT: ret
6060
%c = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 0, i32 2>
6161
ret <2 x double> %c
@@ -95,7 +95,7 @@ define <4 x i32> @shufflevector_pack_od_v4i32(<4 x i32> %a, <4 x i32> %b) {
9595
define <2 x i64> @shufflodector_pack_od_v2i64(<2 x i64> %a, <2 x i64> %b) {
9696
; CHECK-LABEL: shufflodector_pack_od_v2i64:
9797
; CHECK: # %bb.0:
98-
; CHECK-NEXT: vshuf4i.d $vr0, $vr1, 13
98+
; CHECK-NEXT: vpackod.d $vr0, $vr1, $vr0
9999
; CHECK-NEXT: ret
100100
%c = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 1, i32 3>
101101
ret <2 x i64> %c
@@ -115,7 +115,7 @@ define <4 x float> @shufflodector_pack_od_v4f32(<4 x float> %a, <4 x float> %b)
115115
define <2 x double> @shufflodector_pack_od_v2f64(<2 x double> %a, <2 x double> %b) {
116116
; CHECK-LABEL: shufflodector_pack_od_v2f64:
117117
; CHECK: # %bb.0:
118-
; CHECK-NEXT: vshuf4i.d $vr0, $vr1, 13
118+
; CHECK-NEXT: vpackod.d $vr0, $vr1, $vr0
119119
; CHECK-NEXT: ret
120120
%c = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 1, i32 3>
121121
ret <2 x double> %c

llvm/test/CodeGen/LoongArch/lsx/vec-shuffle-byte-shift.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ define <2 x i64> @shuffle_2i64_vbsll_v_8(<2 x i64> %a) nounwind {
230230
; CHECK-LABEL: shuffle_2i64_vbsll_v_8:
231231
; CHECK: # %bb.0:
232232
; CHECK-NEXT: vrepli.b $vr1, 0
233-
; CHECK-NEXT: vshuf4i.d $vr0, $vr1, 2
233+
; CHECK-NEXT: vpackev.d $vr0, $vr0, $vr1
234234
; CHECK-NEXT: ret
235235
%shuffle = shufflevector <2 x i64> %a, <2 x i64> zeroinitializer, <2 x i32> <i32 2, i32 0>
236236
ret <2 x i64> %shuffle

0 commit comments

Comments
 (0)