[llvm] [AMDGPU] - Add bitreplicate const folding tests (PR #72649)

via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 17 05:10:07 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-amdgpu

Author: Jessica Del (OutOfCache)

<details>
<summary>Changes</summary>

Add more test cases for `s_bitreplicate` constant folding.

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


1 Files Affected:

- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.bitreplicate.ll (+46) 


``````````diff
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.bitreplicate.ll b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.bitreplicate.ll
index 0937280e6352c80..815e5c709ff7cb9 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.bitreplicate.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.bitreplicate.ll
@@ -16,6 +16,52 @@ entry:
   ret i64 %br
 }
 
+define i64 @test_s_bitreplicate_constant_zero() {
+; GFX11-LABEL: test_s_bitreplicate_constant_zero:
+; GFX11:       ; %bb.0: ; %entry
+; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX11-NEXT:    v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, 0
+; GFX11-NEXT:    s_setpc_b64 s[30:31]
+entry:
+  %br = call i64 @llvm.amdgcn.s.bitreplicate(i32 0)
+  ret i64 %br
+}
+
+define i64 @test_s_bitreplicate_constant_neg_one() {
+; GFX11-LABEL: test_s_bitreplicate_constant_neg_one:
+; GFX11:       ; %bb.0: ; %entry
+; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX11-NEXT:    v_dual_mov_b32 v0, -1 :: v_dual_mov_b32 v1, -1
+; GFX11-NEXT:    s_setpc_b64 s[30:31]
+entry:
+  %br = call i64 @llvm.amdgcn.s.bitreplicate(i32 -1)
+  ret i64 %br
+}
+
+define i64 @test_s_bitreplicate_constant_undef() {
+; GFX11-LABEL: test_s_bitreplicate_constant_undef:
+; GFX11:       ; %bb.0: ; %entry
+; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX11-NEXT:    s_bitreplicate_b64_b32 s[0:1], s0
+; GFX11-NEXT:    v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
+; GFX11-NEXT:    s_setpc_b64 s[30:31]
+entry:
+  %br = call i64 @llvm.amdgcn.s.bitreplicate(i32 undef)
+  ret i64 %br
+}
+
+define i64 @test_s_bitreplicate_constant_poison() {
+; GFX11-LABEL: test_s_bitreplicate_constant_poison:
+; GFX11:       ; %bb.0: ; %entry
+; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX11-NEXT:    s_bitreplicate_b64_b32 s[0:1], s0
+; GFX11-NEXT:    v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
+; GFX11-NEXT:    s_setpc_b64 s[30:31]
+entry:
+  %br = call i64 @llvm.amdgcn.s.bitreplicate(i32 poison)
+  ret i64 %br
+}
+
 define amdgpu_cs void @test_s_bitreplicate_sgpr(i32 inreg %mask, ptr addrspace(1) %out) {
 ; GFX11-LABEL: test_s_bitreplicate_sgpr:
 ; GFX11:       ; %bb.0: ; %entry

``````````

</details>


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


More information about the llvm-commits mailing list