summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQi Zhao <zhaoqi01@loongson.cn>2025-10-24 19:22:59 +0800
committerQi Zhao <zhaoqi01@loongson.cn>2025-11-21 15:11:00 +0800
commita967cb69fd5504c89b49cd6f567c5bdc724dbff4 (patch)
tree7496cb41000ac5a5d13cb60a68100b4ef4640d97
parentf38bb557b1408dcd502b73f586cefe802b11738a (diff)
-rw-r--r--llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp4
-rw-r--r--llvm/test/CodeGen/LoongArch/lasx/ir-instruction/shuffle-as-xvpermi.ll8
-rw-r--r--llvm/test/CodeGen/LoongArch/lasx/ir-instruction/shuffle-as-xvshuf.ll6
-rw-r--r--llvm/test/CodeGen/LoongArch/lsx/ir-instruction/shuffle-as-vpermi.ll8
-rw-r--r--llvm/test/CodeGen/LoongArch/lsx/ir-instruction/shuffle-as-vshuf.ll6
-rw-r--r--llvm/test/CodeGen/LoongArch/lsx/widen-shuffle-mask.ll9
6 files changed, 23 insertions, 18 deletions
diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
index fa9e71ae7e52..012fe4aed124 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -2079,7 +2079,7 @@ static SDValue lowerVECTOR_SHUFFLE_VPERMI(const SDLoc &DL, ArrayRef<int> Mask,
if (!buildVPERMIInfo(Mask, V1, V2, SrcVec, MaskImm))
return SDValue();
- return DAG.getNode(LoongArchISD::VPERMI, DL, VT, SrcVec[0], SrcVec[1],
+ return DAG.getNode(LoongArchISD::VPERMI, DL, VT, SrcVec[1], SrcVec[0],
DAG.getConstant(MaskImm, DL, Subtarget.getGRLenVT()));
}
@@ -2256,7 +2256,7 @@ lowerVECTOR_SHUFFLE_XVPERMI(const SDLoc &DL, ArrayRef<int> Mask, MVT VT,
if (!buildVPERMIInfo(Mask, V1, V2, SrcVec, MaskImm))
return SDValue();
- return DAG.getNode(LoongArchISD::VPERMI, DL, VT, SrcVec[0], SrcVec[1],
+ return DAG.getNode(LoongArchISD::VPERMI, DL, VT, SrcVec[1], SrcVec[0],
DAG.getConstant(MaskImm, DL, GRLenVT));
}
diff --git a/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/shuffle-as-xvpermi.ll b/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/shuffle-as-xvpermi.ll
index 372e053ae64f..a2e3a280f8db 100644
--- a/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/shuffle-as-xvpermi.ll
+++ b/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/shuffle-as-xvpermi.ll
@@ -8,8 +8,8 @@ define void @shufflevector_xvpermi_v8i32(ptr %res, ptr %a, ptr %b) nounwind {
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: xvld $xr0, $a1, 0
; CHECK-NEXT: xvld $xr1, $a2, 0
-; CHECK-NEXT: xvpermi.w $xr0, $xr1, 78
-; CHECK-NEXT: xvst $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.w $xr1, $xr0, 78
+; CHECK-NEXT: xvst $xr1, $a0, 0
; CHECK-NEXT: ret
entry:
%va = load <8 x i32>, ptr %a
@@ -25,8 +25,8 @@ define void @shufflevector_xvpermi_v8f32(ptr %res, ptr %a, ptr %b) nounwind {
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: xvld $xr0, $a1, 0
; CHECK-NEXT: xvld $xr1, $a2, 0
-; CHECK-NEXT: xvpermi.w $xr1, $xr0, 141
-; CHECK-NEXT: xvst $xr1, $a0, 0
+; CHECK-NEXT: xvpermi.w $xr0, $xr1, 141
+; CHECK-NEXT: xvst $xr0, $a0, 0
; CHECK-NEXT: ret
entry:
%va = load <8 x float>, ptr %a
diff --git a/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/shuffle-as-xvshuf.ll b/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/shuffle-as-xvshuf.ll
index a9bdbf9525df..008e31227efd 100644
--- a/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/shuffle-as-xvshuf.ll
+++ b/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/shuffle-as-xvshuf.ll
@@ -35,9 +35,9 @@ define <16 x i16> @shufflevector_v16i16(<16 x i16> %a, <16 x i16> %b) {
define <8 x i32> @shufflevector_v8i32(<8 x i32> %a, <8 x i32> %b) {
; CHECK-LABEL: shufflevector_v8i32:
; CHECK: # %bb.0:
-; CHECK-NEXT: xvpermi.d $xr2, $xr0, 68
-; CHECK-NEXT: xvpermi.d $xr0, $xr1, 68
-; CHECK-NEXT: xvpermi.w $xr0, $xr2, 180
+; CHECK-NEXT: xvpermi.d $xr1, $xr1, 68
+; CHECK-NEXT: xvpermi.d $xr0, $xr0, 68
+; CHECK-NEXT: xvpermi.w $xr0, $xr1, 180
; CHECK-NEXT: ret
%c = shufflevector <8 x i32> %a, <8 x i32> %b, <8 x i32> <i32 8, i32 9, i32 3, i32 2, i32 8, i32 9, i32 3, i32 2>
ret <8 x i32> %c
diff --git a/llvm/test/CodeGen/LoongArch/lsx/ir-instruction/shuffle-as-vpermi.ll b/llvm/test/CodeGen/LoongArch/lsx/ir-instruction/shuffle-as-vpermi.ll
index 39ca00def281..994515152d73 100644
--- a/llvm/test/CodeGen/LoongArch/lsx/ir-instruction/shuffle-as-vpermi.ll
+++ b/llvm/test/CodeGen/LoongArch/lsx/ir-instruction/shuffle-as-vpermi.ll
@@ -8,8 +8,8 @@ define void @shufflevector_vpermi_v4i32(ptr %res, ptr %a, ptr %b) nounwind {
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vld $vr0, $a1, 0
; CHECK-NEXT: vld $vr1, $a2, 0
-; CHECK-NEXT: vpermi.w $vr0, $vr1, 78
-; CHECK-NEXT: vst $vr0, $a0, 0
+; CHECK-NEXT: vpermi.w $vr1, $vr0, 78
+; CHECK-NEXT: vst $vr1, $a0, 0
; CHECK-NEXT: ret
entry:
%va = load <4 x i32>, ptr %a
@@ -25,8 +25,8 @@ define void @shufflevector_vpermi_v4f32(ptr %res, ptr %a, ptr %b) nounwind {
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vld $vr0, $a1, 0
; CHECK-NEXT: vld $vr1, $a2, 0
-; CHECK-NEXT: vpermi.w $vr1, $vr0, 141
-; CHECK-NEXT: vst $vr1, $a0, 0
+; CHECK-NEXT: vpermi.w $vr0, $vr1, 141
+; CHECK-NEXT: vst $vr0, $a0, 0
; CHECK-NEXT: ret
entry:
%va = load <4 x float>, ptr %a
diff --git a/llvm/test/CodeGen/LoongArch/lsx/ir-instruction/shuffle-as-vshuf.ll b/llvm/test/CodeGen/LoongArch/lsx/ir-instruction/shuffle-as-vshuf.ll
index d9c8563e8a9b..7cdc085c6e5c 100644
--- a/llvm/test/CodeGen/LoongArch/lsx/ir-instruction/shuffle-as-vshuf.ll
+++ b/llvm/test/CodeGen/LoongArch/lsx/ir-instruction/shuffle-as-vshuf.ll
@@ -30,7 +30,8 @@ define <8 x i16> @shufflevector_v8i16(<8 x i16> %a, <8 x i16> %b) {
define <4 x i32> @shufflevector_v4i32(<4 x i32> %a, <4 x i32> %b) {
; CHECK-LABEL: shufflevector_v4i32:
; CHECK: # %bb.0:
-; CHECK-NEXT: vpermi.w $vr0, $vr1, 220
+; CHECK-NEXT: vpermi.w $vr1, $vr0, 220
+; CHECK-NEXT: vori.b $vr0, $vr1, 0
; CHECK-NEXT: ret
%c = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 3, i32 5, i32 7>
ret <4 x i32> %c
@@ -50,7 +51,8 @@ define <2 x i64> @shufflevector_v2i64(<2 x i64> %a, <2 x i64> %b) {
define <4 x float> @shufflevector_v4f32(<4 x float> %a, <4 x float> %b) {
; CHECK-LABEL: shufflevector_v4f32:
; CHECK: # %bb.0:
-; CHECK-NEXT: vpermi.w $vr0, $vr1, 220
+; CHECK-NEXT: vpermi.w $vr1, $vr0, 220
+; CHECK-NEXT: vori.b $vr0, $vr1, 0
; CHECK-NEXT: ret
%c = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 3, i32 5, i32 7>
ret <4 x float> %c
diff --git a/llvm/test/CodeGen/LoongArch/lsx/widen-shuffle-mask.ll b/llvm/test/CodeGen/LoongArch/lsx/widen-shuffle-mask.ll
index 83359e3340bd..4e04bf3dc4f7 100644
--- a/llvm/test/CodeGen/LoongArch/lsx/widen-shuffle-mask.ll
+++ b/llvm/test/CodeGen/LoongArch/lsx/widen-shuffle-mask.ll
@@ -29,7 +29,8 @@ define <16 x i8> @widen_shuffle_mask_v16i8_to_v4i32(<16 x i8> %a, <16 x i8> %b)
define <16 x i8> @widen_shuffle_mask_v16i8_to_v2i64(<16 x i8> %a, <16 x i8> %b) {
; CHECK-LABEL: widen_shuffle_mask_v16i8_to_v2i64:
; CHECK: # %bb.0:
-; CHECK-NEXT: vpermi.w $vr0, $vr1, 228
+; CHECK-NEXT: vpermi.w $vr1, $vr0, 228
+; CHECK-NEXT: vori.b $vr0, $vr1, 0
; CHECK-NEXT: ret
%r = shufflevector <16 x i8> %a, <16 x i8> %b, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
ret <16 x i8> %r
@@ -50,7 +51,8 @@ define <8 x i16> @widen_shuffle_mask_v8i16_to_v4i32(<8 x i16> %a, <8 x i16> %b)
define <8 x i16> @widen_shuffle_mask_v8i16_to_v2i64(<8 x i16> %a, <8 x i16> %b) {
; CHECK-LABEL: widen_shuffle_mask_v8i16_to_v2i64:
; CHECK: # %bb.0:
-; CHECK-NEXT: vpermi.w $vr0, $vr1, 228
+; CHECK-NEXT: vpermi.w $vr1, $vr0, 228
+; CHECK-NEXT: vori.b $vr0, $vr1, 0
; CHECK-NEXT: ret
%r = shufflevector <8 x i16> %a, <8 x i16> %b, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 12, i32 13, i32 14, i32 15>
ret <8 x i16> %r
@@ -59,7 +61,8 @@ define <8 x i16> @widen_shuffle_mask_v8i16_to_v2i64(<8 x i16> %a, <8 x i16> %b)
define <4 x i32> @widen_shuffle_mask_v4i32_to_v2i64(<4 x i32> %a, <4 x i32> %b) {
; CHECK-LABEL: widen_shuffle_mask_v4i32_to_v2i64:
; CHECK: # %bb.0:
-; CHECK-NEXT: vpermi.w $vr0, $vr1, 228
+; CHECK-NEXT: vpermi.w $vr1, $vr0, 228
+; CHECK-NEXT: vori.b $vr0, $vr1, 0
; CHECK-NEXT: ret
%r = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 6, i32 7>
ret <4 x i32> %r