1 # RUN: llc -mtriple=amdgcn -verify-machineinstrs -run-pass si-shrink-instructions -o - %s | FileCheck -check-prefix=GCN %s
2 # RUN: llc -mtriple=amdgcn -verify-machineinstrs -passes si-shrink-instructions -o - %s | FileCheck -check-prefix=GCN %s
5 define amdgpu_kernel void @fold_fi_vgpr() {
6 %alloca = alloca [4 x i32], addrspace(5)
10 define amdgpu_kernel void @fold_vgpr_fi() {
11 %alloca = alloca [4 x i32], addrspace(5)
15 define amdgpu_kernel void @fold_sgpr_fi() {
16 %alloca = alloca [4 x i32], addrspace(5)
20 define amdgpu_kernel void @fold_fi_sgpr() {
21 %alloca = alloca [4 x i32], addrspace(5)
25 define amdgpu_kernel void @fold_fi_imm() {
26 %alloca = alloca [4 x i32], addrspace(5)
30 define amdgpu_kernel void @fold_imm_fi() {
31 %alloca = alloca [4 x i32], addrspace(5)
36 # GCN-LABEL: name: fold_fi_vgpr{{$}}
37 # GCN: %1:vgpr_32 = IMPLICIT_DEF
39 # GCN: %2:vgpr_32 = V_ADD_CO_U32_e32 %stack.0.alloca, %1, implicit-def $vcc, implicit $exec
41 tracksRegLiveness: true
43 - { id: 0, class: vgpr_32 }
44 - { id: 1, class: vgpr_32 }
45 - { id: 2, class: vgpr_32 }
47 - { id: 0, name: alloca, type: default, offset: 0, size: 128, alignment: 8,
48 callee-saved-register: '', local-offset: 0, debug-info-variable: '',
49 debug-info-expression: '', debug-info-location: '' }
52 %0 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
54 %2, $vcc = V_ADD_CO_U32_e64 %0, %1, 0, implicit $exec
58 # GCN-LABEL: name: fold_vgpr_fi{{$}}
59 # GCN: %1:vgpr_32 = IMPLICIT_DEF
60 # GCN: %2:vgpr_32 = V_ADD_CO_U32_e32 %stack.0.alloca, %1, implicit-def $vcc, implicit $exec
62 tracksRegLiveness: true
64 - { id: 0, class: vgpr_32 }
65 - { id: 1, class: vgpr_32 }
66 - { id: 2, class: vgpr_32 }
68 - { id: 0, name: alloca, type: default, offset: 0, size: 128, alignment: 8,
69 callee-saved-register: '', local-offset: 0, debug-info-variable: '',
70 debug-info-expression: '', debug-info-location: '' }
73 %0 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
75 %2, $vcc = V_ADD_CO_U32_e64 %1, %0, 0, implicit $exec
79 # GCN-LABEL: name: fold_sgpr_fi{{$}}
80 # GCN: %0:vgpr_32 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
81 # GCN: %1:sgpr_32 = IMPLICIT_DEF
82 # GCN: %2:vgpr_32 = V_ADD_CO_U32_e32 %1, %0, implicit-def $vcc, implicit $exec
84 tracksRegLiveness: true
86 - { id: 0, class: vgpr_32 }
87 - { id: 1, class: sgpr_32 }
88 - { id: 2, class: vgpr_32 }
90 - { id: 0, name: alloca, type: default, offset: 0, size: 128, alignment: 8,
91 callee-saved-register: '', local-offset: 0, debug-info-variable: '',
92 debug-info-expression: '', debug-info-location: '' }
95 %0 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
97 %2, $vcc = V_ADD_CO_U32_e64 %1, %0, 0, implicit $exec
101 # GCN-LABEL: name: fold_fi_sgpr{{$}}
102 # GCN: %0:vgpr_32 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
103 # GCN: %1:sgpr_32 = IMPLICIT_DEF
104 # GCN: %2:vgpr_32 = V_ADD_CO_U32_e32 %1, %0, implicit-def $vcc, implicit $exec
106 tracksRegLiveness: true
108 - { id: 0, class: vgpr_32 }
109 - { id: 1, class: sgpr_32 }
110 - { id: 2, class: vgpr_32 }
112 - { id: 0, name: alloca, type: default, offset: 0, size: 128, alignment: 8,
113 callee-saved-register: '', local-offset: 0, debug-info-variable: '',
114 debug-info-expression: '', debug-info-location: '' }
117 %0 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
119 %2, $vcc = V_ADD_CO_U32_e64 %0, %1, 0, implicit $exec
122 # TODO: Should probably prefer folding immediate first
123 # GCN-LABEL: name: fold_fi_imm{{$}}
124 # GCN: %1:vgpr_32 = V_MOV_B32_e32 999, implicit $exec
125 # GCN: %2:vgpr_32 = V_ADD_CO_U32_e32 %stack.0.alloca, %1, implicit-def $vcc, implicit $exec
127 tracksRegLiveness: true
129 - { id: 0, class: vgpr_32 }
130 - { id: 1, class: vgpr_32 }
131 - { id: 2, class: vgpr_32 }
133 - { id: 0, name: alloca, type: default, offset: 0, size: 128, alignment: 8,
134 callee-saved-register: '', local-offset: 0, debug-info-variable: '',
135 debug-info-expression: '', debug-info-location: '' }
138 %0 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
139 %1 = V_MOV_B32_e32 999, implicit $exec
140 %2, $vcc = V_ADD_CO_U32_e64 %0, %1, 0, implicit $exec
144 # GCN-LABEL: name: fold_imm_fi{{$}}
145 # GCN: %0:vgpr_32 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
146 # GCN: %2:vgpr_32 = V_ADD_CO_U32_e32 999, %0, implicit-def $vcc, implicit $exec
148 tracksRegLiveness: true
150 - { id: 0, class: vgpr_32 }
151 - { id: 1, class: vgpr_32 }
152 - { id: 2, class: vgpr_32 }
154 - { id: 0, name: alloca, type: default, offset: 0, size: 128, alignment: 8,
155 callee-saved-register: '', local-offset: 0, debug-info-variable: '',
156 debug-info-expression: '', debug-info-location: '' }
159 %0 = V_MOV_B32_e32 %stack.0.alloca, implicit $exec
160 %1 = V_MOV_B32_e32 999, implicit $exec
161 %2, $vcc = V_ADD_CO_U32_e64 %1, %0, 0, implicit $exec