Repository navigation
[NFC][AMDGPU] New test for untested case in SILowerI1Copies - #186127
Conversation
🪟 Windows x64 Test Results
✅ The build succeeded and all tests passed. |
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
|
Ours is the only test that fails in the presence of the
|
|
@llvm/pr-subscribers-backend-amdgpu Author: None (ambergorzynski) ChangesThis line is untested by the existing LLVM test suite (checked using code coverage and by inserting an We propose a new test that exercises this case. The test is demonstrated by adding an abort to show that it is the only test that fails (the abort is removed before merging). 1 Files Affected:
diff --git a/llvm/test/CodeGen/AMDGPU/si-lower-i1-copies.ll b/llvm/test/CodeGen/AMDGPU/si-lower-i1-copies.ll
new file mode 100644
index 0000000000000..afc2d830e1743
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/si-lower-i1-copies.ll
@@ -0,0 +1,149 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -O1 < %s | FileCheck %s
+
+declare void @bar(ptr captures(none)) #0
+
+define void @foo(i32 %0) #0 {
+; CHECK-LABEL: foo:
+; CHECK: ; %bb.0: ; %entry
+; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; CHECK-NEXT: s_mov_b32 s16, s33
+; CHECK-NEXT: s_mov_b32 s33, s32
+; CHECK-NEXT: s_or_saveexec_b64 s[18:19], -1
+; CHECK-NEXT: buffer_store_dword v42, off, s[0:3], s33 offset:8 ; 4-byte Folded Spill
+; CHECK-NEXT: s_mov_b64 exec, s[18:19]
+; CHECK-NEXT: v_writelane_b32 v42, s16, 20
+; CHECK-NEXT: s_addk_i32 s32, 0x400
+; CHECK-NEXT: buffer_store_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill
+; CHECK-NEXT: buffer_store_dword v41, off, s[0:3], s33 ; 4-byte Folded Spill
+; CHECK-NEXT: v_writelane_b32 v42, s30, 0
+; CHECK-NEXT: v_writelane_b32 v42, s31, 1
+; CHECK-NEXT: v_writelane_b32 v42, s34, 2
+; CHECK-NEXT: v_writelane_b32 v42, s35, 3
+; CHECK-NEXT: v_writelane_b32 v42, s36, 4
+; CHECK-NEXT: v_writelane_b32 v42, s37, 5
+; CHECK-NEXT: v_writelane_b32 v42, s38, 6
+; CHECK-NEXT: v_writelane_b32 v42, s39, 7
+; CHECK-NEXT: v_writelane_b32 v42, s48, 8
+; CHECK-NEXT: v_writelane_b32 v42, s49, 9
+; CHECK-NEXT: v_writelane_b32 v42, s50, 10
+; CHECK-NEXT: v_writelane_b32 v42, s51, 11
+; CHECK-NEXT: v_writelane_b32 v42, s52, 12
+; CHECK-NEXT: v_writelane_b32 v42, s53, 13
+; CHECK-NEXT: v_writelane_b32 v42, s54, 14
+; CHECK-NEXT: v_writelane_b32 v42, s55, 15
+; CHECK-NEXT: v_writelane_b32 v42, s64, 16
+; CHECK-NEXT: v_writelane_b32 v42, s65, 17
+; CHECK-NEXT: v_writelane_b32 v42, s66, 18
+; CHECK-NEXT: v_writelane_b32 v42, s67, 19
+; CHECK-NEXT: v_mov_b32_e32 v40, v31
+; CHECK-NEXT: v_mov_b32_e32 v41, v0
+; CHECK-NEXT: s_mov_b32 s52, s15
+; CHECK-NEXT: s_mov_b32 s53, s14
+; CHECK-NEXT: s_mov_b32 s54, s13
+; CHECK-NEXT: s_mov_b32 s55, s12
+; CHECK-NEXT: s_mov_b64 s[34:35], s[10:11]
+; CHECK-NEXT: s_mov_b64 s[36:37], s[8:9]
+; CHECK-NEXT: s_mov_b64 s[38:39], s[6:7]
+; CHECK-NEXT: s_mov_b64 s[48:49], s[4:5]
+; CHECK-NEXT: s_mov_b64 s[64:65], 0
+; CHECK-NEXT: v_cmp_gt_i32_e64 s[50:51], 0, v41
+; CHECK-NEXT: ; implicit-def: $sgpr4_sgpr5
+; CHECK-NEXT: s_mov_b64 s[6:7], 0
+; CHECK-NEXT: s_branch .LBB0_2
+; CHECK-NEXT: .LBB0_1: ; %Flow
+; CHECK-NEXT: ; in Loop: Header=BB0_2 Depth=1
+; CHECK-NEXT: s_or_b64 exec, exec, s[66:67]
+; CHECK-NEXT: s_and_b64 s[4:5], exec, s[6:7]
+; CHECK-NEXT: s_or_b64 s[64:65], s[4:5], s[64:65]
+; CHECK-NEXT: ; implicit-def: $sgpr4_sgpr5
+; CHECK-NEXT: s_mov_b64 s[6:7], 0
+; CHECK-NEXT: s_andn2_b64 exec, exec, s[64:65]
+; CHECK-NEXT: s_cbranch_execz .LBB0_5
+; CHECK-NEXT: .LBB0_2: ; %for.cond
+; CHECK-NEXT: ; =>This Inner Loop Header: Depth=1
+; CHECK-NEXT: v_cmp_lt_i32_e32 vcc, -1, v41
+; CHECK-NEXT: s_andn2_b64 s[4:5], s[4:5], exec
+; CHECK-NEXT: s_and_b64 s[8:9], s[50:51], exec
+; CHECK-NEXT: s_or_b64 s[4:5], s[4:5], s[8:9]
+; CHECK-NEXT: s_or_b64 s[6:7], vcc, s[6:7]
+; CHECK-NEXT: s_andn2_b64 exec, exec, s[6:7]
+; CHECK-NEXT: s_cbranch_execnz .LBB0_2
+; CHECK-NEXT: ; %bb.3: ; %BB
+; CHECK-NEXT: ; in Loop: Header=BB0_2 Depth=1
+; CHECK-NEXT: s_or_b64 exec, exec, s[6:7]
+; CHECK-NEXT: s_mov_b64 s[6:7], -1
+; CHECK-NEXT: s_and_saveexec_b64 s[66:67], s[4:5]
+; CHECK-NEXT: s_cbranch_execz .LBB0_1
+; CHECK-NEXT: ; %bb.4: ; %for.body
+; CHECK-NEXT: ; in Loop: Header=BB0_2 Depth=1
+; CHECK-NEXT: s_getpc_b64 s[4:5]
+; CHECK-NEXT: s_add_u32 s4, s4, bar@gotpcrel32@lo+4
+; CHECK-NEXT: s_addc_u32 s5, s5, bar@gotpcrel32@hi+12
+; CHECK-NEXT: s_load_dwordx2 s[16:17], s[4:5], 0x0
+; CHECK-NEXT: v_mov_b32_e32 v1, 0
+; CHECK-NEXT: s_mov_b64 s[4:5], s[48:49]
+; CHECK-NEXT: s_mov_b64 s[6:7], s[38:39]
+; CHECK-NEXT: s_mov_b64 s[8:9], s[36:37]
+; CHECK-NEXT: s_mov_b64 s[10:11], s[34:35]
+; CHECK-NEXT: s_mov_b32 s12, s55
+; CHECK-NEXT: s_mov_b32 s13, s54
+; CHECK-NEXT: s_mov_b32 s14, s53
+; CHECK-NEXT: s_mov_b32 s15, s52
+; CHECK-NEXT: v_mov_b32_e32 v31, v40
+; CHECK-NEXT: s_waitcnt lgkmcnt(0)
+; CHECK-NEXT: s_swappc_b64 s[30:31], s[16:17]
+; CHECK-NEXT: s_xor_b64 s[6:7], exec, -1
+; CHECK-NEXT: s_branch .LBB0_1
+; CHECK-NEXT: .LBB0_5: ; %for.cond.cleanup
+; CHECK-NEXT: s_or_b64 exec, exec, s[64:65]
+; CHECK-NEXT: v_readlane_b32 s67, v42, 19
+; CHECK-NEXT: v_readlane_b32 s66, v42, 18
+; CHECK-NEXT: v_readlane_b32 s65, v42, 17
+; CHECK-NEXT: v_readlane_b32 s64, v42, 16
+; CHECK-NEXT: v_readlane_b32 s55, v42, 15
+; CHECK-NEXT: v_readlane_b32 s54, v42, 14
+; CHECK-NEXT: v_readlane_b32 s53, v42, 13
+; CHECK-NEXT: v_readlane_b32 s52, v42, 12
+; CHECK-NEXT: v_readlane_b32 s51, v42, 11
+; CHECK-NEXT: v_readlane_b32 s50, v42, 10
+; CHECK-NEXT: v_readlane_b32 s49, v42, 9
+; CHECK-NEXT: v_readlane_b32 s48, v42, 8
+; CHECK-NEXT: v_readlane_b32 s39, v42, 7
+; CHECK-NEXT: v_readlane_b32 s38, v42, 6
+; CHECK-NEXT: v_readlane_b32 s37, v42, 5
+; CHECK-NEXT: v_readlane_b32 s36, v42, 4
+; CHECK-NEXT: v_readlane_b32 s35, v42, 3
+; CHECK-NEXT: v_readlane_b32 s34, v42, 2
+; CHECK-NEXT: v_readlane_b32 s31, v42, 1
+; CHECK-NEXT: v_readlane_b32 s30, v42, 0
+; CHECK-NEXT: buffer_load_dword v41, off, s[0:3], s33 ; 4-byte Folded Reload
+; CHECK-NEXT: buffer_load_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload
+; CHECK-NEXT: s_mov_b32 s32, s33
+; CHECK-NEXT: v_readlane_b32 s4, v42, 20
+; CHECK-NEXT: s_or_saveexec_b64 s[6:7], -1
+; CHECK-NEXT: buffer_load_dword v42, off, s[0:3], s33 offset:8 ; 4-byte Folded Reload
+; CHECK-NEXT: s_mov_b64 exec, s[6:7]
+; CHECK-NEXT: s_mov_b32 s33, s4
+; CHECK-NEXT: s_waitcnt vmcnt(0)
+; CHECK-NEXT: s_setpc_b64 s[30:31]
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.body, %for.cond, %entry
+ %cmp1 = icmp slt i32 %0, 0
+ br i1 %cmp1, label %for.cond, label %BB
+
+BB: ; preds = %for.cond
+ br i1 %cmp1, label %for.body, label %for.cond.cleanup
+
+for.cond.cleanup: ; preds = %BB
+ ret void
+
+for.body: ; preds = %BB
+ call void @bar(ptr poison)
+ br label %for.cond
+}
+
+attributes #0 = { nounwind }
+
|
ro-i
left a comment
There was a problem hiding this comment.
LGTM, given that the test is already reduced/minimal
| @@ -0,0 +1,149 @@ | |||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 | |||
| ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O1 < %s | FileCheck %s | |||
There was a problem hiding this comment.
Without -O1, the untested case is no longer covered (tested by finding that without -O1, the test no longer fails in the presence of the abort)
There was a problem hiding this comment.
si-lower-i1-copies runs regardless of the optimization level, right?
It runs after AMDGPU DAG->DAG Pattern Instruction Selection and SI Fix SGPR copies which also run regardless of the optimization level.
In that case, would it be possible to recover the LLVM-IR just before instruction selection and try compiling that code without -O1?
There was a problem hiding this comment.
Edit: maybe stop before the structurizer and see if that works (pass --stop-before=structurizecfg to llc). Otherwise you'll have to use --start-before= which may be awkward.
| @@ -0,0 +1,149 @@ | |||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 | |||
| ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O1 < %s | FileCheck %s | |||
There was a problem hiding this comment.
Test name is too general, can you add this to an existing test
There was a problem hiding this comment.
The existing tests for this pass are in MIR rather than LLVM IR. Do you think it would be better for me to convert this test to MIR also?
There was a problem hiding this comment.
Probably yes, especially if it's dependent on -O1
There was a problem hiding this comment.
I converted to MIR, renamed, and added to an existing test file for this pass. It now runs just the si-i1-copies pass. The existing test didn't have checks so I added them for the whole file using utils/update_mir_test_checks.py. I checked that the test still works as intended: it fails only if an abort is inserted in the untested case (I can push some evidence of this if you like).
Let me know any other changes I should make.
This line is untested by the existing LLVM test suite (checked using code coverage and by inserting an
abort).We propose a new test that exercises this case. The test is demonstrated by adding an abort to show that it is the only test that fails (the abort is removed before merging).