[llvm] [LoongArch] Pre-commit test for vreplgr2vr + vinsgr2vr intrinsics (PR #115702)

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 11 01:50:16 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-loongarch

Author: ZhaoQi (zhaoqi5)

<details>
<summary>Changes</summary>

Inspired by https://github.com/llvm/llvm-project/issues/101624.

A later commit will optimize it.

---
Full diff: https://github.com/llvm/llvm-project/pull/115702.diff


2 Files Affected:

- (added) llvm/test/CodeGen/LoongArch/lasx/intrinsic-repl-ins-gr2vr.ll (+39) 
- (added) llvm/test/CodeGen/LoongArch/lsx/intrinsic-repl-ins-gr2vr.ll (+81) 


``````````diff
diff --git a/llvm/test/CodeGen/LoongArch/lasx/intrinsic-repl-ins-gr2vr.ll b/llvm/test/CodeGen/LoongArch/lasx/intrinsic-repl-ins-gr2vr.ll
new file mode 100644
index 00000000000000..b3dcd373b60e08
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/lasx/intrinsic-repl-ins-gr2vr.ll
@@ -0,0 +1,39 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc --mtriple=loongarch64 --mattr=+lasx < %s | FileCheck %s
+
+define <8 x i32> @xvrepl_ins_w(i32 %a, i32 %b) {
+; CHECK-LABEL: xvrepl_ins_w:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    xvinsgr2vr.w $xr0, $a0, 0
+; CHECK-NEXT:    xvinsgr2vr.w $xr0, $a1, 1
+; CHECK-NEXT:    xvinsgr2vr.w $xr0, $a0, 2
+; CHECK-NEXT:    xvinsgr2vr.w $xr0, $a0, 3
+; CHECK-NEXT:    xvinsgr2vr.w $xr0, $a0, 4
+; CHECK-NEXT:    xvinsgr2vr.w $xr0, $a0, 5
+; CHECK-NEXT:    xvinsgr2vr.w $xr0, $a0, 6
+; CHECK-NEXT:    xvinsgr2vr.w $xr0, $a0, 7
+; CHECK-NEXT:    ret
+entry:
+  %0 = call <8 x i32> @llvm.loongarch.lasx.xvreplgr2vr.w(i32 %a)
+  %1 = call <8 x i32> @llvm.loongarch.lasx.xvinsgr2vr.w(<8 x i32> %0, i32 %b, i32 1)
+  ret <8 x i32> %1
+}
+
+define <4 x i64> @xvrepl_ins_d(i64 %a, i64 %b) {
+; CHECK-LABEL: xvrepl_ins_d:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    xvinsgr2vr.d $xr0, $a0, 0
+; CHECK-NEXT:    xvinsgr2vr.d $xr0, $a1, 1
+; CHECK-NEXT:    xvinsgr2vr.d $xr0, $a0, 2
+; CHECK-NEXT:    xvinsgr2vr.d $xr0, $a0, 3
+; CHECK-NEXT:    ret
+entry:
+  %0 = call <4 x i64> @llvm.loongarch.lasx.xvreplgr2vr.d(i64 %a)
+  %1 = call <4 x i64> @llvm.loongarch.lasx.xvinsgr2vr.d(<4 x i64> %0, i64 %b, i32 1)
+  ret <4 x i64> %1
+}
+
+declare <8 x i32> @llvm.loongarch.lasx.xvinsgr2vr.w(<8 x i32>, i32, i32 immarg)
+declare <8 x i32> @llvm.loongarch.lasx.xvreplgr2vr.w(i32)
+declare <4 x i64> @llvm.loongarch.lasx.xvinsgr2vr.d(<4 x i64>, i64, i32 immarg)
+declare <4 x i64> @llvm.loongarch.lasx.xvreplgr2vr.d(i64)
diff --git a/llvm/test/CodeGen/LoongArch/lsx/intrinsic-repl-ins-gr2vr.ll b/llvm/test/CodeGen/LoongArch/lsx/intrinsic-repl-ins-gr2vr.ll
new file mode 100644
index 00000000000000..3eb06149010402
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/lsx/intrinsic-repl-ins-gr2vr.ll
@@ -0,0 +1,81 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc --mtriple=loongarch64 --mattr=+lsx < %s | FileCheck %s
+
+define <16 x i8> @vrepl_ins_b(i32 %a, i32 %b) {
+; CHECK-LABEL: vrepl_ins_b:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 0
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a1, 1
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 2
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 3
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 4
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 5
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 6
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 7
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 8
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 9
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 10
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 11
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 12
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 13
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 14
+; CHECK-NEXT:    vinsgr2vr.b $vr0, $a0, 15
+; CHECK-NEXT:    ret
+entry:
+  %0 = call <16 x i8> @llvm.loongarch.lsx.vreplgr2vr.b(i32 %a)
+  %1 = call <16 x i8> @llvm.loongarch.lsx.vinsgr2vr.b(<16 x i8> %0, i32 %b, i32 1)
+  ret <16 x i8> %1
+}
+
+define <8 x i16> @vrepl_ins_h(i32 %a, i32 %b) {
+; CHECK-LABEL: vrepl_ins_h:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    vinsgr2vr.h $vr0, $a0, 0
+; CHECK-NEXT:    vinsgr2vr.h $vr0, $a1, 1
+; CHECK-NEXT:    vinsgr2vr.h $vr0, $a0, 2
+; CHECK-NEXT:    vinsgr2vr.h $vr0, $a0, 3
+; CHECK-NEXT:    vinsgr2vr.h $vr0, $a0, 4
+; CHECK-NEXT:    vinsgr2vr.h $vr0, $a0, 5
+; CHECK-NEXT:    vinsgr2vr.h $vr0, $a0, 6
+; CHECK-NEXT:    vinsgr2vr.h $vr0, $a0, 7
+; CHECK-NEXT:    ret
+entry:
+  %0 = call <8 x i16> @llvm.loongarch.lsx.vreplgr2vr.h(i32 %a)
+  %1 = call <8 x i16> @llvm.loongarch.lsx.vinsgr2vr.h(<8 x i16> %0, i32 %b, i32 1)
+  ret <8 x i16> %1
+}
+
+define <4 x i32> @vrepl_ins_w(i32 %a, i32 %b) {
+; CHECK-LABEL: vrepl_ins_w:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    vinsgr2vr.w $vr0, $a0, 0
+; CHECK-NEXT:    vinsgr2vr.w $vr0, $a1, 1
+; CHECK-NEXT:    vinsgr2vr.w $vr0, $a0, 2
+; CHECK-NEXT:    vinsgr2vr.w $vr0, $a0, 3
+; CHECK-NEXT:    ret
+entry:
+  %0 = call <4 x i32> @llvm.loongarch.lsx.vreplgr2vr.w(i32 %a)
+  %1 = call <4 x i32> @llvm.loongarch.lsx.vinsgr2vr.w(<4 x i32> %0, i32 %b, i32 1)
+  ret <4 x i32> %1
+}
+
+define <2 x i64> @vrepl_ins_d(i64 %a, i64 %b) {
+; CHECK-LABEL: vrepl_ins_d:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    vinsgr2vr.d $vr0, $a0, 0
+; CHECK-NEXT:    vinsgr2vr.d $vr0, $a1, 1
+; CHECK-NEXT:    ret
+entry:
+  %0 = call <2 x i64> @llvm.loongarch.lsx.vreplgr2vr.d(i64 %a)
+  %1 = call <2 x i64> @llvm.loongarch.lsx.vinsgr2vr.d(<2 x i64> %0, i64 %b, i32 1)
+  ret <2 x i64> %1
+}
+
+declare <16 x i8> @llvm.loongarch.lsx.vinsgr2vr.b(<16 x i8>, i32, i32 immarg)
+declare <16 x i8> @llvm.loongarch.lsx.vreplgr2vr.b(i32)
+declare <8 x i16> @llvm.loongarch.lsx.vinsgr2vr.h(<8 x i16>, i32, i32 immarg)
+declare <8 x i16> @llvm.loongarch.lsx.vreplgr2vr.h(i32)
+declare <4 x i32> @llvm.loongarch.lsx.vinsgr2vr.w(<4 x i32>, i32, i32 immarg)
+declare <4 x i32> @llvm.loongarch.lsx.vreplgr2vr.w(i32)
+declare <2 x i64> @llvm.loongarch.lsx.vinsgr2vr.d(<2 x i64>, i64, i32 immarg)
+declare <2 x i64> @llvm.loongarch.lsx.vreplgr2vr.d(i64)

``````````

</details>


https://github.com/llvm/llvm-project/pull/115702


More information about the llvm-commits mailing list