Skip to content

Commit 02d2c1d

Browse files
committed
reorder the lower shuffle opertation
1 parent 01f5bd0 commit 02d2c1d

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,11 +1383,6 @@ static SDValue lower128BitShuffle(const SDLoc &DL, ArrayRef<int> Mask, MVT VT,
13831383
/* V2 = V1; */
13841384
}
13851385

1386-
if (VT.SimpleTy == MVT::v2i64 || VT.SimpleTy == MVT::v2f64) {
1387-
if ((Result = lowerVECTOR_SHUFFLE_VSHUF4I(DL, Mask, VT, V1, V2, DAG)))
1388-
return Result;
1389-
}
1390-
13911386
// It is recommended not to change the pattern comparison order for better
13921387
// performance.
13931388
if ((Result = lowerVECTOR_SHUFFLE_VPACKEV(DL, Mask, VT, V1, V2, DAG)))
@@ -1402,6 +1397,9 @@ static SDValue lower128BitShuffle(const SDLoc &DL, ArrayRef<int> Mask, MVT VT,
14021397
return Result;
14031398
if ((Result = lowerVECTOR_SHUFFLE_VPICKOD(DL, Mask, VT, V1, V2, DAG)))
14041399
return Result;
1400+
if ((VT.SimpleTy == MVT::v2i64 || VT.SimpleTy == MVT::v2f64) &&
1401+
(Result = lowerVECTOR_SHUFFLE_VSHUF4I(DL, Mask, VT, V1, V2, DAG)))
1402+
return Result;
14051403
if ((Result = lowerVECTOR_SHUFFLEAsZeroOrAnyExtend(DL, Mask, VT, V1, V2, DAG,
14061404
Zeroable)))
14071405
return Result;
@@ -1827,11 +1825,6 @@ static SDValue lower256BitShuffle(const SDLoc &DL, ArrayRef<int> Mask, MVT VT,
18271825
/* V2 = V1; */
18281826
}
18291827

1830-
if (VT.SimpleTy == MVT::v4i64 || VT.SimpleTy == MVT::v4f64) {
1831-
if ((Result = lowerVECTOR_SHUFFLE_XVSHUF4I(DL, NewMask, VT, V1, V2, DAG)))
1832-
return Result;
1833-
}
1834-
18351828
// It is recommended not to change the pattern comparison order for better
18361829
// performance.
18371830
if ((Result = lowerVECTOR_SHUFFLE_XVPACKEV(DL, NewMask, VT, V1, V2, DAG)))
@@ -1846,6 +1839,9 @@ static SDValue lower256BitShuffle(const SDLoc &DL, ArrayRef<int> Mask, MVT VT,
18461839
return Result;
18471840
if ((Result = lowerVECTOR_SHUFFLE_XVPICKOD(DL, NewMask, VT, V1, V2, DAG)))
18481841
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;
18491845
if ((Result =
18501846
lowerVECTOR_SHUFFLEAsShift(DL, NewMask, VT, V1, V2, DAG, Zeroable)))
18511847
return Result;

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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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)