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,2 -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: SI_SPILL_V32_SAVE killed $vgpr2, %stack.5, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.5, addrspace 5)
12 ; REGALLOC-NEXT: SI_SPILL_V32_SAVE killed $vgpr1, %stack.4, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.4, addrspace 5)
13 ; REGALLOC-NEXT: renamable $sgpr4 = S_MOV_B32 49
14 ; REGALLOC-NEXT: renamable $sgpr4_sgpr5 = V_CMP_GT_I32_e64 killed $vgpr0, killed $sgpr4, implicit $exec
15 ; REGALLOC-NEXT: renamable $sgpr6 = IMPLICIT_DEF
16 ; REGALLOC-NEXT: renamable $vgpr0 = COPY killed renamable $sgpr6
17 ; REGALLOC-NEXT: SI_SPILL_V32_SAVE killed $vgpr0, %stack.3, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.3, addrspace 5)
18 ; REGALLOC-NEXT: renamable $sgpr6_sgpr7 = COPY $exec, implicit-def $exec
19 ; REGALLOC-NEXT: renamable $sgpr4_sgpr5 = S_AND_B64 renamable $sgpr6_sgpr7, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
20 ; REGALLOC-NEXT: renamable $sgpr6_sgpr7 = S_XOR_B64 renamable $sgpr4_sgpr5, killed renamable $sgpr6_sgpr7, implicit-def dead $scc
21 ; REGALLOC-NEXT: $vgpr63 = IMPLICIT_DEF
22 ; REGALLOC-NEXT: $vgpr63 = SI_SPILL_S32_TO_VGPR killed $sgpr6, 0, $vgpr63, implicit-def $sgpr6_sgpr7, implicit $sgpr6_sgpr7
23 ; REGALLOC-NEXT: $vgpr63 = SI_SPILL_S32_TO_VGPR killed $sgpr7, 1, $vgpr63, implicit killed $sgpr6_sgpr7
24 ; REGALLOC-NEXT: SI_SPILL_WWM_V32_SAVE killed $vgpr63, %stack.2, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.2, addrspace 5)
25 ; REGALLOC-NEXT: $exec = S_MOV_B64_term killed renamable $sgpr4_sgpr5
26 ; REGALLOC-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
27 ; REGALLOC-NEXT: S_BRANCH %bb.3
28 ; REGALLOC-NEXT: {{ $}}
29 ; REGALLOC-NEXT: bb.1.Flow:
30 ; REGALLOC-NEXT: successors: %bb.2(0x40000000), %bb.4(0x40000000)
31 ; REGALLOC-NEXT: {{ $}}
32 ; REGALLOC-NEXT: $vgpr63 = SI_SPILL_WWM_V32_RESTORE %stack.2, $sgpr32, 0, implicit $exec :: (load (s32) from %stack.2, addrspace 5)
33 ; REGALLOC-NEXT: $sgpr4 = SI_RESTORE_S32_FROM_VGPR $vgpr63, 0, implicit-def $sgpr4_sgpr5
34 ; REGALLOC-NEXT: $sgpr5 = SI_RESTORE_S32_FROM_VGPR $vgpr63, 1
35 ; REGALLOC-NEXT: renamable $sgpr4_sgpr5 = S_OR_SAVEEXEC_B64 killed renamable $sgpr4_sgpr5, implicit-def $exec, implicit-def dead $scc, implicit $exec
36 ; REGALLOC-NEXT: $vgpr0 = SI_SPILL_V32_RESTORE %stack.3, $sgpr32, 0, implicit $exec :: (load (s32) from %stack.3, addrspace 5)
37 ; REGALLOC-NEXT: SI_SPILL_V32_SAVE killed $vgpr0, %stack.6, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.6, addrspace 5)
38 ; REGALLOC-NEXT: renamable $sgpr4_sgpr5 = S_AND_B64 $exec, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
39 ; REGALLOC-NEXT: $vgpr63 = SI_SPILL_S32_TO_VGPR killed $sgpr4, 2, $vgpr63, implicit-def $sgpr4_sgpr5, implicit $sgpr4_sgpr5
40 ; REGALLOC-NEXT: $vgpr63 = SI_SPILL_S32_TO_VGPR $sgpr5, 3, $vgpr63, implicit $sgpr4_sgpr5
41 ; REGALLOC-NEXT: SI_SPILL_WWM_V32_SAVE killed $vgpr63, %stack.2, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.2, addrspace 5)
42 ; REGALLOC-NEXT: $exec = S_XOR_B64_term $exec, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
43 ; REGALLOC-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
44 ; REGALLOC-NEXT: S_BRANCH %bb.2
45 ; REGALLOC-NEXT: {{ $}}
46 ; REGALLOC-NEXT: bb.2.bb.1:
47 ; REGALLOC-NEXT: successors: %bb.4(0x80000000)
48 ; REGALLOC-NEXT: {{ $}}
49 ; REGALLOC-NEXT: $vgpr0 = SI_SPILL_V32_RESTORE %stack.4, $sgpr32, 0, implicit $exec :: (load (s32) from %stack.4, addrspace 5)
50 ; REGALLOC-NEXT: renamable $sgpr4 = S_MOV_B32 10
51 ; REGALLOC-NEXT: renamable $vgpr0 = V_ADD_U32_e64 $vgpr0, killed $sgpr4, 0, implicit $exec
52 ; REGALLOC-NEXT: SI_SPILL_V32_SAVE killed $vgpr0, %stack.6, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.6, addrspace 5)
53 ; REGALLOC-NEXT: S_BRANCH %bb.4
54 ; REGALLOC-NEXT: {{ $}}
55 ; REGALLOC-NEXT: bb.3.bb.2:
56 ; REGALLOC-NEXT: successors: %bb.1(0x80000000)
57 ; REGALLOC-NEXT: {{ $}}
58 ; REGALLOC-NEXT: $vgpr0 = SI_SPILL_V32_RESTORE %stack.5, $sgpr32, 0, implicit $exec :: (load (s32) from %stack.5, addrspace 5)
59 ; REGALLOC-NEXT: renamable $sgpr4 = S_MOV_B32 20
60 ; REGALLOC-NEXT: renamable $vgpr0 = V_ADD_U32_e64 $vgpr0, killed $sgpr4, 0, implicit $exec
61 ; REGALLOC-NEXT: SI_SPILL_V32_SAVE killed $vgpr0, %stack.3, $sgpr32, 0, implicit $exec :: (store (s32) into %stack.3, addrspace 5)
62 ; REGALLOC-NEXT: S_BRANCH %bb.1
63 ; REGALLOC-NEXT: {{ $}}
64 ; REGALLOC-NEXT: bb.4.bb.3:
65 ; REGALLOC-NEXT: $vgpr63 = SI_SPILL_WWM_V32_RESTORE %stack.2, $sgpr32, 0, implicit $exec :: (load (s32) from %stack.2, addrspace 5)
66 ; REGALLOC-NEXT: $sgpr4 = SI_RESTORE_S32_FROM_VGPR $vgpr63, 2, implicit-def $sgpr4_sgpr5
67 ; REGALLOC-NEXT: $sgpr5 = SI_RESTORE_S32_FROM_VGPR killed $vgpr63, 3
68 ; REGALLOC-NEXT: $exec = S_OR_B64 $exec, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
69 ; REGALLOC-NEXT: $vgpr0 = SI_SPILL_V32_RESTORE %stack.6, $sgpr32, 0, implicit $exec :: (load (s32) from %stack.6, addrspace 5)
70 ; REGALLOC-NEXT: renamable $vgpr0 = V_LSHL_ADD_U32_e64 killed $vgpr0, 2, $vgpr0, implicit $exec
71 ; REGALLOC-NEXT: SI_RETURN implicit killed $vgpr0
73 %cmp = icmp slt i32 %arg0, 50
74 br i1 %cmp, label %bb.1, label %bb.2
77 %val1 = add i32 %arg1, 10
81 %val2 = add i32 %arg2, 20
85 %val = phi i32 [ %val1, %bb.1 ], [ %val2, %bb.2 ]
86 %ret = mul i32 %val, 5;