-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[LoongArch] Pre-commit tests for vecreduce_and/or/... #154879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-backend-loongarch Author: None (tangaac) ChangesPatch is 67.94 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/154879.diff 14 Files Affected:
diff --git a/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-and.ll b/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-and.ll
new file mode 100644
index 0000000000000..a3160f10c8ca8
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-and.ll
@@ -0,0 +1,95 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc --mtriple=loongarch64 --mattr=+lasx %s -o - | FileCheck %s
+
+define void @vec_reduce_and_v32i8(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_and_v32i8:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.b $xr1, $xr1, 228
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvbsrl.v $xr1, $xr1, 8
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvsrli.d $xr1, $xr1, 32
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.b $xr1, $xr1, 14
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.b $xr1, $xr1, 1
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.b $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <32 x i8>, ptr %src
+ %res = call i8 @llvm.vector.reduce.and.v32i8(<32 x i8> %v)
+ store i8 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_and_v16i16(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_and_v16i16:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.h $xr1, $xr1, 228
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvbsrl.v $xr1, $xr1, 8
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.h $xr1, $xr1, 14
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.h $xr1, $xr1, 1
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.h $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <16 x i16>, ptr %src
+ %res = call i16 @llvm.vector.reduce.and.v16i16(<16 x i16> %v)
+ store i16 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_and_v8i32(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_and_v8i32:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.w $xr1, $xr1, 228
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.w $xr1, $xr1, 14
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.w $xr1, $xr1, 1
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.w $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <8 x i32>, ptr %src
+ %res = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> %v)
+ store i32 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_and_v4i64(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_and_v4i64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: pcalau12i $a0, %pc_hi20(.LCPI3_0)
+; CHECK-NEXT: xvld $xr1, $a0, %pc_lo12(.LCPI3_0)
+; CHECK-NEXT: xvpermi.d $xr2, $xr0, 78
+; CHECK-NEXT: xvshuf.d $xr1, $xr0, $xr2
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.d $xr1, $xr1, 1
+; CHECK-NEXT: xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.d $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <4 x i64>, ptr %src
+ %res = call i64 @llvm.vector.reduce.and.v4i64(<4 x i64> %v)
+ store i64 %res, ptr %dst
+ ret void
+}
+
diff --git a/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-or.ll b/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-or.ll
new file mode 100644
index 0000000000000..bc910c23e4b17
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-or.ll
@@ -0,0 +1,95 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc --mtriple=loongarch64 --mattr=+lasx %s -o - | FileCheck %s
+
+define void @vec_reduce_or_v32i8(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_or_v32i8:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.b $xr1, $xr1, 228
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvbsrl.v $xr1, $xr1, 8
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvsrli.d $xr1, $xr1, 32
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.b $xr1, $xr1, 14
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.b $xr1, $xr1, 1
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.b $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <32 x i8>, ptr %src
+ %res = call i8 @llvm.vector.reduce.or.v32i8(<32 x i8> %v)
+ store i8 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_or_v16i16(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_or_v16i16:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.h $xr1, $xr1, 228
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvbsrl.v $xr1, $xr1, 8
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.h $xr1, $xr1, 14
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.h $xr1, $xr1, 1
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.h $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <16 x i16>, ptr %src
+ %res = call i16 @llvm.vector.reduce.or.v16i16(<16 x i16> %v)
+ store i16 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_or_v8i32(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_or_v8i32:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.w $xr1, $xr1, 228
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.w $xr1, $xr1, 14
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.w $xr1, $xr1, 1
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.w $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <8 x i32>, ptr %src
+ %res = call i32 @llvm.vector.reduce.or.v8i32(<8 x i32> %v)
+ store i32 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_or_v4i64(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_or_v4i64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: pcalau12i $a0, %pc_hi20(.LCPI3_0)
+; CHECK-NEXT: xvld $xr1, $a0, %pc_lo12(.LCPI3_0)
+; CHECK-NEXT: xvpermi.d $xr2, $xr0, 78
+; CHECK-NEXT: xvshuf.d $xr1, $xr0, $xr2
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.d $xr1, $xr1, 1
+; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.d $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <4 x i64>, ptr %src
+ %res = call i64 @llvm.vector.reduce.or.v4i64(<4 x i64> %v)
+ store i64 %res, ptr %dst
+ ret void
+}
+
diff --git a/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-smax.ll b/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-smax.ll
new file mode 100644
index 0000000000000..378088c9f8280
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-smax.ll
@@ -0,0 +1,95 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc --mtriple=loongarch64 --mattr=+lasx %s -o - | FileCheck %s
+
+define void @vec_reduce_smax_v32i8(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_smax_v32i8:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.b $xr1, $xr1, 228
+; CHECK-NEXT: xvmax.b $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvbsrl.v $xr1, $xr1, 8
+; CHECK-NEXT: xvmax.b $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvsrli.d $xr1, $xr1, 32
+; CHECK-NEXT: xvmax.b $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.b $xr1, $xr1, 14
+; CHECK-NEXT: xvmax.b $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.b $xr1, $xr1, 1
+; CHECK-NEXT: xvmax.b $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.b $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <32 x i8>, ptr %src
+ %res = call i8 @llvm.vector.reduce.smax.v32i8(<32 x i8> %v)
+ store i8 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_smax_v16i16(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_smax_v16i16:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.h $xr1, $xr1, 228
+; CHECK-NEXT: xvmax.h $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvbsrl.v $xr1, $xr1, 8
+; CHECK-NEXT: xvmax.h $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.h $xr1, $xr1, 14
+; CHECK-NEXT: xvmax.h $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.h $xr1, $xr1, 1
+; CHECK-NEXT: xvmax.h $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.h $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <16 x i16>, ptr %src
+ %res = call i16 @llvm.vector.reduce.smax.v16i16(<16 x i16> %v)
+ store i16 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_smax_v8i32(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_smax_v8i32:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.w $xr1, $xr1, 228
+; CHECK-NEXT: xvmax.w $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.w $xr1, $xr1, 14
+; CHECK-NEXT: xvmax.w $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.w $xr1, $xr1, 1
+; CHECK-NEXT: xvmax.w $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.w $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <8 x i32>, ptr %src
+ %res = call i32 @llvm.vector.reduce.smax.v8i32(<8 x i32> %v)
+ store i32 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_smax_v4i64(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_smax_v4i64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: pcalau12i $a0, %pc_hi20(.LCPI3_0)
+; CHECK-NEXT: xvld $xr1, $a0, %pc_lo12(.LCPI3_0)
+; CHECK-NEXT: xvpermi.d $xr2, $xr0, 78
+; CHECK-NEXT: xvshuf.d $xr1, $xr0, $xr2
+; CHECK-NEXT: xvmax.d $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.d $xr1, $xr1, 1
+; CHECK-NEXT: xvmax.d $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.d $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <4 x i64>, ptr %src
+ %res = call i64 @llvm.vector.reduce.smax.v4i64(<4 x i64> %v)
+ store i64 %res, ptr %dst
+ ret void
+}
+
diff --git a/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-smin.ll b/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-smin.ll
new file mode 100644
index 0000000000000..1c7f2054cd4e1
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-smin.ll
@@ -0,0 +1,95 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc --mtriple=loongarch64 --mattr=+lasx %s -o - | FileCheck %s
+
+define void @vec_reduce_smin_v32i8(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_smin_v32i8:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.b $xr1, $xr1, 228
+; CHECK-NEXT: xvmin.b $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvbsrl.v $xr1, $xr1, 8
+; CHECK-NEXT: xvmin.b $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvsrli.d $xr1, $xr1, 32
+; CHECK-NEXT: xvmin.b $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.b $xr1, $xr1, 14
+; CHECK-NEXT: xvmin.b $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.b $xr1, $xr1, 1
+; CHECK-NEXT: xvmin.b $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.b $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <32 x i8>, ptr %src
+ %res = call i8 @llvm.vector.reduce.smin.v32i8(<32 x i8> %v)
+ store i8 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_smin_v16i16(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_smin_v16i16:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.h $xr1, $xr1, 228
+; CHECK-NEXT: xvmin.h $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvbsrl.v $xr1, $xr1, 8
+; CHECK-NEXT: xvmin.h $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.h $xr1, $xr1, 14
+; CHECK-NEXT: xvmin.h $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.h $xr1, $xr1, 1
+; CHECK-NEXT: xvmin.h $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.h $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <16 x i16>, ptr %src
+ %res = call i16 @llvm.vector.reduce.smin.v16i16(<16 x i16> %v)
+ store i16 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_smin_v8i32(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_smin_v8i32:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.w $xr1, $xr1, 228
+; CHECK-NEXT: xvmin.w $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.w $xr1, $xr1, 14
+; CHECK-NEXT: xvmin.w $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.w $xr1, $xr1, 1
+; CHECK-NEXT: xvmin.w $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.w $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <8 x i32>, ptr %src
+ %res = call i32 @llvm.vector.reduce.smin.v8i32(<8 x i32> %v)
+ store i32 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_smin_v4i64(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_smin_v4i64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: pcalau12i $a0, %pc_hi20(.LCPI3_0)
+; CHECK-NEXT: xvld $xr1, $a0, %pc_lo12(.LCPI3_0)
+; CHECK-NEXT: xvpermi.d $xr2, $xr0, 78
+; CHECK-NEXT: xvshuf.d $xr1, $xr0, $xr2
+; CHECK-NEXT: xvmin.d $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.d $xr1, $xr1, 1
+; CHECK-NEXT: xvmin.d $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.d $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <4 x i64>, ptr %src
+ %res = call i64 @llvm.vector.reduce.smin.v4i64(<4 x i64> %v)
+ store i64 %res, ptr %dst
+ ret void
+}
+
diff --git a/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-umax.ll b/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-umax.ll
new file mode 100644
index 0000000000000..152f093cbd025
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-umax.ll
@@ -0,0 +1,95 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc --mtriple=loongarch64 --mattr=+lasx %s -o - | FileCheck %s
+
+define void @vec_reduce_umax_v32i8(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_umax_v32i8:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.b $xr1, $xr1, 228
+; CHECK-NEXT: xvmax.bu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvbsrl.v $xr1, $xr1, 8
+; CHECK-NEXT: xvmax.bu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvsrli.d $xr1, $xr1, 32
+; CHECK-NEXT: xvmax.bu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.b $xr1, $xr1, 14
+; CHECK-NEXT: xvmax.bu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.b $xr1, $xr1, 1
+; CHECK-NEXT: xvmax.bu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.b $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <32 x i8>, ptr %src
+ %res = call i8 @llvm.vector.reduce.umax.v32i8(<32 x i8> %v)
+ store i8 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_umax_v16i16(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_umax_v16i16:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.h $xr1, $xr1, 228
+; CHECK-NEXT: xvmax.hu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvbsrl.v $xr1, $xr1, 8
+; CHECK-NEXT: xvmax.hu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.h $xr1, $xr1, 14
+; CHECK-NEXT: xvmax.hu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.h $xr1, $xr1, 1
+; CHECK-NEXT: xvmax.hu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.h $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <16 x i16>, ptr %src
+ %res = call i16 @llvm.vector.reduce.umax.v16i16(<16 x i16> %v)
+ store i16 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_umax_v8i32(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_umax_v8i32:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.w $xr1, $xr1, 228
+; CHECK-NEXT: xvmax.wu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.w $xr1, $xr1, 14
+; CHECK-NEXT: xvmax.wu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.w $xr1, $xr1, 1
+; CHECK-NEXT: xvmax.wu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.w $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <8 x i32>, ptr %src
+ %res = call i32 @llvm.vector.reduce.umax.v8i32(<8 x i32> %v)
+ store i32 %res, ptr %dst
+ ret void
+}
+
+define void @vec_reduce_umax_v4i64(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_umax_v4i64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: pcalau12i $a0, %pc_hi20(.LCPI3_0)
+; CHECK-NEXT: xvld $xr1, $a0, %pc_lo12(.LCPI3_0)
+; CHECK-NEXT: xvpermi.d $xr2, $xr0, 78
+; CHECK-NEXT: xvshuf.d $xr1, $xr0, $xr2
+; CHECK-NEXT: xvmax.du $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvrepl128vei.d $xr1, $xr1, 1
+; CHECK-NEXT: xvmax.du $xr0, $xr0, $xr1
+; CHECK-NEXT: xvstelm.d $xr0, $a1, 0, 0
+; CHECK-NEXT: ret
+ %v = load <4 x i64>, ptr %src
+ %res = call i64 @llvm.vector.reduce.umax.v4i64(<4 x i64> %v)
+ store i64 %res, ptr %dst
+ ret void
+}
+
diff --git a/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-umin.ll b/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-umin.ll
new file mode 100644
index 0000000000000..64ed377535abf
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/lasx/vec-reduce-umin.ll
@@ -0,0 +1,95 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc --mtriple=loongarch64 --mattr=+lasx %s -o - | FileCheck %s
+
+define void @vec_reduce_umin_v32i8(ptr %src, ptr %dst) nounwind {
+; CHECK-LABEL: vec_reduce_umin_v32i8:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xvld $xr0, $a0, 0
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 78
+; CHECK-NEXT: xvshuf4i.b $xr1, $xr1, 228
+; CHECK-NEXT: xvmin.bu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvbsrl.v $xr1, $xr1, 8
+; CHECK-NEXT: xvmin.bu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvsrli.d $xr1, $xr1, 32
+; CHECK-NEXT: xvmin.bu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $xr0, 68
+; CHECK-NEXT: xvshuf4i.b $xr1, $xr1, 14
+; CHECK-NEXT: xvmin.bu $xr0, $xr0, $xr1
+; CHECK-NEXT: xvpermi.d $xr1, $...
[truncated]
|
heiher
approved these changes
Aug 22, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.