1 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx906 -O0 -verify-machineinstrs --stop-after=regallocfast,1 -o - %s | FileCheck -check-prefix=REGALLOC %s
4 ; Test to check if the bb prolog spills are inserted correctly during regalloc.
5 define i32 @prolog_spill(i32 %arg0, i32 %arg1, i32 %arg2) {
6 ; REGALLOC-LABEL: name: prolog_spill
8 ; REGALLOC-NEXT: successors: %bb.3(0x40000000), %bb.1(0x40000000)
9 ; REGALLOC-NEXT: liveins: $vgpr0, $vgpr1, $vgpr2
10 ; REGALLOC-NEXT: {{ $}}
11 ; REGALLOC-NEXT: renamable $vgpr3 = IMPLICIT_DEF
12 ; REGALLOC-NEXT: SI_SPILL_V32_SAVE killed $vgpr2, %stack.5, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.5, addrspace 5)
13 ; REGALLOC-NEXT: SI_SPILL_V32_SAVE killed $vgpr1, %stack.4, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.4, addrspace 5)
14 ; REGALLOC-NEXT: renamable $vgpr1 = COPY $vgpr0
15 ; REGALLOC-NEXT: $vgpr0 = SI_SPILL_WWM_V32_RESTORE %stack.2, $sgpr32, 0, implicit $exec :: (load (s32) from %stack.2, addrspace 5)
16 ; REGALLOC-NEXT: renamable $sgpr4 = S_MOV_B32 49
17 ; REGALLOC-NEXT: renamable $sgpr4_sgpr5 = V_CMP_GT_I32_e64 killed $vgpr1, killed $sgpr4, implicit $exec
18 ; REGALLOC-NEXT: renamable $sgpr6 = IMPLICIT_DEF
19 ; REGALLOC-NEXT: renamable $vgpr1 = COPY killed renamable $sgpr6
20 ; REGALLOC-NEXT: SI_SPILL_V32_SAVE killed $vgpr1, %stack.3, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.3, addrspace 5)
21 ; REGALLOC-NEXT: renamable $sgpr6_sgpr7 = COPY $exec, implicit-def $exec
22 ; REGALLOC-NEXT: renamable $sgpr4_sgpr5 = S_AND_B64 renamable $sgpr6_sgpr7, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
23 ; REGALLOC-NEXT: renamable $sgpr6_sgpr7 = S_XOR_B64 renamable $sgpr4_sgpr5, killed renamable $sgpr6_sgpr7, implicit-def dead $scc
24 ; REGALLOC-NEXT: renamable $vgpr0 = SI_SPILL_S32_TO_VGPR killed $sgpr6, 0, $vgpr0, implicit-def $sgpr6_sgpr7, implicit $sgpr6_sgpr7
25 ; REGALLOC-NEXT: renamable $vgpr0 = SI_SPILL_S32_TO_VGPR killed $sgpr7, 1, $vgpr0, implicit killed $sgpr6_sgpr7
26 ; REGALLOC-NEXT: SI_SPILL_WWM_V32_SAVE killed $vgpr0, %stack.2, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.2, addrspace 5)
27 ; REGALLOC-NEXT: $exec = S_MOV_B64_term killed renamable $sgpr4_sgpr5
28 ; REGALLOC-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
29 ; REGALLOC-NEXT: S_BRANCH %bb.3
30 ; REGALLOC-NEXT: {{ $}}
31 ; REGALLOC-NEXT: bb.1.Flow:
32 ; REGALLOC-NEXT: successors: %bb.2(0x40000000), %bb.4(0x40000000)
33 ; REGALLOC-NEXT: {{ $}}
34 ; REGALLOC-NEXT: $vgpr0 = SI_SPILL_WWM_V32_RESTORE %stack.2, $sgpr32, 0, implicit $exec :: (load (s32) from %stack.2, addrspace 5)
35 ; REGALLOC-NEXT: $sgpr4 = SI_RESTORE_S32_FROM_VGPR $vgpr0, 0, implicit-def $sgpr4_sgpr5
36 ; REGALLOC-NEXT: $sgpr5 = SI_RESTORE_S32_FROM_VGPR $vgpr0, 1
37 ; REGALLOC-NEXT: renamable $sgpr4_sgpr5 = S_OR_SAVEEXEC_B64 killed renamable $sgpr4_sgpr5, implicit-def $exec, implicit-def dead $scc, implicit $exec
38 ; REGALLOC-NEXT: $vgpr1 = SI_SPILL_V32_RESTORE %stack.3, $sgpr32, 0, implicit $exec :: (load (s32) from %stack.3, addrspace 5)
39 ; REGALLOC-NEXT: SI_SPILL_V32_SAVE killed $vgpr1, %stack.6, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.6, addrspace 5)
40 ; REGALLOC-NEXT: renamable $sgpr4_sgpr5 = S_AND_B64 $exec, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
41 ; REGALLOC-NEXT: renamable $vgpr0 = SI_SPILL_S32_TO_VGPR killed $sgpr4, 2, $vgpr0, implicit-def $sgpr4_sgpr5, implicit $sgpr4_sgpr5
42 ; REGALLOC-NEXT: renamable $vgpr0 = SI_SPILL_S32_TO_VGPR $sgpr5, 3, $vgpr0, implicit $sgpr4_sgpr5
43 ; REGALLOC-NEXT: SI_SPILL_WWM_V32_SAVE killed $vgpr0, %stack.2, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.2, addrspace 5)
44 ; REGALLOC-NEXT: $exec = S_XOR_B64_term $exec, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
45 ; REGALLOC-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
46 ; REGALLOC-NEXT: S_BRANCH %bb.2
47 ; REGALLOC-NEXT: {{ $}}
48 ; REGALLOC-NEXT: bb.2.bb.1:
49 ; REGALLOC-NEXT: successors: %bb.4(0x80000000)
50 ; REGALLOC-NEXT: {{ $}}
51 ; REGALLOC-NEXT: $vgpr0 = SI_SPILL_V32_RESTORE %stack.4, $sgpr32, 0, implicit $exec :: (load (s32) from %stack.4, addrspace 5)
52 ; REGALLOC-NEXT: renamable $sgpr4 = S_MOV_B32 10
53 ; REGALLOC-NEXT: renamable $vgpr0 = V_ADD_U32_e64 $vgpr0, killed $sgpr4, 0, implicit $exec
54 ; REGALLOC-NEXT: SI_SPILL_V32_SAVE killed $vgpr0, %stack.6, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.6, addrspace 5)
55 ; REGALLOC-NEXT: S_BRANCH %bb.4
56 ; REGALLOC-NEXT: {{ $}}
57 ; REGALLOC-NEXT: bb.3.bb.2:
58 ; REGALLOC-NEXT: successors: %bb.1(0x80000000)
59 ; REGALLOC-NEXT: {{ $}}
60 ; REGALLOC-NEXT: $vgpr0 = SI_SPILL_V32_RESTORE %stack.5, $sgpr32, 0, implicit $exec :: (load (s32) from %stack.5, addrspace 5)
61 ; REGALLOC-NEXT: renamable $sgpr4 = S_MOV_B32 20
62 ; REGALLOC-NEXT: renamable $vgpr0 = V_ADD_U32_e64 $vgpr0, killed $sgpr4, 0, implicit $exec
63 ; REGALLOC-NEXT: SI_SPILL_V32_SAVE killed $vgpr0, %stack.3, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.3, addrspace 5)
64 ; REGALLOC-NEXT: S_BRANCH %bb.1
65 ; REGALLOC-NEXT: {{ $}}
66 ; REGALLOC-NEXT: bb.4.bb.3:
67 ; REGALLOC-NEXT: $vgpr1 = SI_SPILL_WWM_V32_RESTORE %stack.2, $sgpr32, 0, implicit $exec :: (load (s32) from %stack.2, addrspace 5)
68 ; REGALLOC-NEXT: $sgpr4 = SI_RESTORE_S32_FROM_VGPR $vgpr1, 2, implicit-def $sgpr4_sgpr5
69 ; REGALLOC-NEXT: $sgpr5 = SI_RESTORE_S32_FROM_VGPR $vgpr1, 3
70 ; REGALLOC-NEXT: $exec = S_OR_B64 $exec, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
71 ; REGALLOC-NEXT: $vgpr0 = SI_SPILL_V32_RESTORE %stack.6, $sgpr32, 0, implicit $exec :: (load (s32) from %stack.6, addrspace 5)
72 ; REGALLOC-NEXT: renamable $vgpr0 = V_LSHL_ADD_U32_e64 killed $vgpr0, 2, $vgpr0, implicit $exec
73 ; REGALLOC-NEXT: KILL killed renamable $vgpr1
74 ; REGALLOC-NEXT: SI_RETURN implicit killed $vgpr0
76 %cmp = icmp slt i32 %arg0, 50
77 br i1 %cmp, label %bb.1, label %bb.2
80 %val1 = add i32 %arg1, 10
84 %val2 = add i32 %arg2, 20
88 %val = phi i32 [ %val1, %bb.1 ], [ %val2, %bb.2 ]
89 %ret = mul i32 %val, 5;