1 # RUN: llc -march=amdgcn -verify-machineinstrs -run-pass si-shrink-instructions -o - %s | FileCheck -check-prefix=GCN %s
4 define amdgpu_kernel void @fold_fi_vgpr() {
5 %alloca = alloca [4 x i32], addrspace(5)
9 define amdgpu_kernel void @fold_vgpr_fi() {
10 %alloca = alloca [4 x i32], addrspace(5)
14 define amdgpu_kernel void @fold_sgpr_fi() {
15 %alloca = alloca [4 x i32], addrspace(5)
19 define amdgpu_kernel void @fold_fi_sgpr() {
20 %alloca = alloca [4 x i32], addrspace(5)
24 define amdgpu_kernel void @fold_fi_imm() {
25 %alloca = alloca [4 x i32], addrspace(5)
29 define amdgpu_kernel void @fold_imm_fi() {
30 %alloca = alloca [4 x i32], addrspace(5)
35 # GCN-LABEL: name: fold_fi_vgpr{{$}}
36 # GCN: %1:vgpr_32 = IMPLICIT_DEF
38 # GCN: %2:vgpr_32 = V_ADD_CO_U32_e32 %stack.0.alloca, %1, implicit-def $vcc, implicit $exec
40 tracksRegLiveness: true
42 - { id: 0, class: vgpr_32 }
43 - { id: 1, class: vgpr_32 }
44 - { id: 2, class: vgpr_32 }
46 - { id: 0, name: alloca, type: default, offset: 0, size: 128, alignment: 8,
47 callee-saved-register: '', local-offset: 0, debug-info-variable: '',
48 debug-info-expression: '', debug-info-location: '' }
51 %0 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
53 %2, $vcc = V_ADD_CO_U32_e64 %0, %1, 0, implicit $exec
57 # GCN-LABEL: name: fold_vgpr_fi{{$}}
58 # GCN: %1:vgpr_32 = IMPLICIT_DEF
59 # GCN: %2:vgpr_32 = V_ADD_CO_U32_e32 %stack.0.alloca, %1, implicit-def $vcc, implicit $exec
61 tracksRegLiveness: true
63 - { id: 0, class: vgpr_32 }
64 - { id: 1, class: vgpr_32 }
65 - { id: 2, class: vgpr_32 }
67 - { id: 0, name: alloca, type: default, offset: 0, size: 128, alignment: 8,
68 callee-saved-register: '', local-offset: 0, debug-info-variable: '',
69 debug-info-expression: '', debug-info-location: '' }
72 %0 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
74 %2, $vcc = V_ADD_CO_U32_e64 %1, %0, 0, implicit $exec
78 # GCN-LABEL: name: fold_sgpr_fi{{$}}
79 # GCN: %0:vgpr_32 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
80 # GCN: %1:sgpr_32 = IMPLICIT_DEF
81 # GCN: %2:vgpr_32 = V_ADD_CO_U32_e32 %1, %0, implicit-def $vcc, implicit $exec
83 tracksRegLiveness: true
85 - { id: 0, class: vgpr_32 }
86 - { id: 1, class: sgpr_32 }
87 - { id: 2, class: vgpr_32 }
89 - { id: 0, name: alloca, type: default, offset: 0, size: 128, alignment: 8,
90 callee-saved-register: '', local-offset: 0, debug-info-variable: '',
91 debug-info-expression: '', debug-info-location: '' }
94 %0 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
96 %2, $vcc = V_ADD_CO_U32_e64 %1, %0, 0, implicit $exec
100 # GCN-LABEL: name: fold_fi_sgpr{{$}}
101 # GCN: %0:vgpr_32 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
102 # GCN: %1:sgpr_32 = IMPLICIT_DEF
103 # GCN: %2:vgpr_32 = V_ADD_CO_U32_e32 %1, %0, implicit-def $vcc, implicit $exec
105 tracksRegLiveness: true
107 - { id: 0, class: vgpr_32 }
108 - { id: 1, class: sgpr_32 }
109 - { id: 2, class: vgpr_32 }
111 - { id: 0, name: alloca, type: default, offset: 0, size: 128, alignment: 8,
112 callee-saved-register: '', local-offset: 0, debug-info-variable: '',
113 debug-info-expression: '', debug-info-location: '' }
116 %0 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
118 %2, $vcc = V_ADD_CO_U32_e64 %0, %1, 0, implicit $exec
121 # TODO: Should probably prefer folding immediate first
122 # GCN-LABEL: name: fold_fi_imm{{$}}
123 # GCN: %1:vgpr_32 = V_MOV_B32_e32 999, implicit $exec
124 # GCN: %2:vgpr_32 = V_ADD_CO_U32_e32 %stack.0.alloca, %1, implicit-def $vcc, implicit $exec
126 tracksRegLiveness: true
128 - { id: 0, class: vgpr_32 }
129 - { id: 1, class: vgpr_32 }
130 - { id: 2, class: vgpr_32 }
132 - { id: 0, name: alloca, type: default, offset: 0, size: 128, alignment: 8,
133 callee-saved-register: '', local-offset: 0, debug-info-variable: '',
134 debug-info-expression: '', debug-info-location: '' }
137 %0 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
138 %1 = V_MOV_B32_e32 999, implicit $exec
139 %2, $vcc = V_ADD_CO_U32_e64 %0, %1, 0, implicit $exec
143 # GCN-LABEL: name: fold_imm_fi{{$}}
144 # GCN: %0:vgpr_32 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
145 # GCN: %2:vgpr_32 = V_ADD_CO_U32_e32 999, %0, implicit-def $vcc, implicit $exec
147 tracksRegLiveness: true
149 - { id: 0, class: vgpr_32 }
150 - { id: 1, class: vgpr_32 }
151 - { id: 2, class: vgpr_32 }
153 - { id: 0, name: alloca, type: default, offset: 0, size: 128, alignment: 8,
154 callee-saved-register: '', local-offset: 0, debug-info-variable: '',
155 debug-info-expression: '', debug-info-location: '' }
158 %0 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
159 %1 = V_MOV_B32_e32 999, implicit $exec
160 %2, $vcc = V_ADD_CO_U32_e64 %1, %0, 0, implicit $exec