OLD | NEW |
---|---|
1 ; RUN: opt %s -expand-struct-regs -S | FileCheck %s | 1 ; RUN: opt %s -expand-struct-regs -S | FileCheck %s |
2 ; RUN: opt %s -expand-struct-regs -S | FileCheck %s -check-prefix=CLEANUP | 2 ; RUN: opt %s -expand-struct-regs -S | FileCheck %s -check-prefix=CLEANUP |
3 | 3 |
4 ; These two instructions should not appear in the output: | 4 ; These two instructions should not appear in the output: |
5 ; CLEANUP-NOT: extractvalue | 5 ; CLEANUP-NOT: extractvalue |
6 ; CLEANUP-NOT: insertvalue | 6 ; CLEANUP-NOT: insertvalue |
7 | 7 |
8 %struct = type { i8, i32 } | 8 %struct = type { i8, i32 } |
9 | 9 |
10 | 10 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 ; CHECK-NEXT: store i32 200, i32* %out1 | 117 ; CHECK-NEXT: store i32 200, i32* %out1 |
118 ; CHECK-NEXT: ret void | 118 ; CHECK-NEXT: ret void |
119 | 119 |
120 | 120 |
121 define i32 @extract_from_constant() { | 121 define i32 @extract_from_constant() { |
122 %ev = extractvalue %struct { i8 99, i32 888 }, 1 | 122 %ev = extractvalue %struct { i8 99, i32 888 }, 1 |
123 ret i32 %ev | 123 ret i32 %ev |
124 } | 124 } |
125 ; CHECK: define i32 @extract_from_constant() { | 125 ; CHECK: define i32 @extract_from_constant() { |
126 ; CHECK-NEXT: ret i32 888 | 126 ; CHECK-NEXT: ret i32 888 |
127 | |
128 define void @nested_structs() { | |
129 %a1 = alloca i64 | |
130 %a2 = alloca i32 | |
131 %a3 = alloca { { i32, i64 } } | |
132 %a = insertvalue { i32, i64 } undef, i32 5, 0 | |
133 %b = insertvalue { i32, i64 } %a, i64 6, 1 | |
134 %c = insertvalue { { i32, i64 } } undef, { i32, i64 } %b, 0 | |
135 %d = insertvalue { { { i32, i64 } }, i64 } undef, { { i32, i64 } } %c, 0 | |
136 %e = insertvalue { { { i32, i64 } }, i64 } undef, { i32, i64 } %b, 0, 0 | |
137 | |
138 %f = extractvalue { { { i32, i64 } }, i64 } %d, 0, 0, 1 | |
139 %g = extractvalue { { { i32, i64 } }, i64 } %e, 0, 0, 0 | |
140 %h = extractvalue { { { i32, i64 } }, i64 } %e, 0 | |
141 store i64 %f, i64* %a1 | |
142 store i32 %g, i32* %a2 | |
143 store { { i32, i64 } } %h, { { i32, i64 } }* %a3 | |
144 ret void | |
145 } | |
146 ; CHECK-LABEL: define void @nested_structs() | |
147 ; CHECK-NEXT: %a1 = alloca i64 | |
148 ; CHECK-NEXT: %a2 = alloca i32 | |
149 ; CHECK-NEXT: %a3 = alloca { { i32, i64 } } | |
150 ; CHECK-NEXT: store i64 6, i64* %a1 | |
151 ; CHECK-NEXT: store i32 5, i32* %a2 | |
152 ; CHECK-NEXT: %a3.index = getelementptr { { i32, i64 } }* %a3, i32 0, i32 0 | |
153 ; CHECK-NEXT: %a3.index.index = getelementptr { i32, i64 }* %a3.index, i32 0, i32 0 | |
154 ; CHECK-NEXT: store i32 5, i32* %a3.index.index, align 1 | |
155 ; CHECK-NEXT: %a3.index.index1 = getelementptr { i32, i64 }* %a3.index, i32 0 , i32 1 | |
156 ; CHECK-NEXT: store i64 6, i64* %a3.index.index1, align 1 | |
157 | |
158 define void @load_another_pass() { | |
159 %a = alloca { { i64 } } | |
160 %b = load { { i64 } }* %a | |
161 ret void | |
162 } | |
163 ; CHECK-LABEL: define void @load_another_pass() | |
164 ; CHECK-NEXT: %a = alloca { { i64 } } | |
165 ; CHECK-NEXT: %b.index = getelementptr { { i64 } }* %a, i32 0, i32 0 | |
166 ; CHECK-NEXT: %b.field.index = getelementptr { i64 }* %b.index, i32 0, i32 0 | |
167 ; CHECK-NEXT: %b.field.field = load i64* %b.field.index, align 1 | |
JF
2014/12/25 17:09:36
Could you have a test for alignment preservation t
Richard Diamond
2014/12/26 01:57:45
This pass didn't preserve alignment before this PR
JF
2014/12/26 18:14:41
That's acceptable, though please note that open so
Richard Diamond
2014/12/27 01:19:37
Ah, I was unaware of MathExtras existence. That si
| |
168 ; CHECK-NEXT: ret void | |
169 | |
170 define void @store_another_pass() { | |
171 %a = alloca { { i64 } } | |
172 store { { i64 } } undef, { { i64 } }* %a | |
173 ret void | |
174 } | |
175 ; CHECK-LABEL: define void @store_another_pass() | |
176 ; CHECK-NEXT: %a = alloca { { i64 } } | |
177 ; CHECK-NEXT: %a.index = getelementptr { { i64 } }* %a, i32 0, i32 0 | |
178 ; CHECK-NEXT: %a.index.index = getelementptr { i64 }* %a.index, i32 0, i32 0 | |
179 ; CHECK-NEXT: store i64 undef, i64* %a.index.index, align 1 | |
180 ; CHECK-NEXT: ret void | |
181 | |
182 define void @select_another_pass() { | |
183 %a = select i1 undef, { { i64 } } undef, { { i64 } } undef | |
184 ret void | |
185 } | |
186 ; CHECK-LABEL: define void @select_another_pass() | |
187 ; CHECK-NEXT: %a.index.index = select i1 undef, i64 undef, i64 undef | |
JF
2014/12/25 17:09:36
Could you also test with a selected value of { { i
Richard Diamond
2014/12/26 01:57:45
I used a local load from null (lol), so there are
| |
188 ; CHECK-NEXT: ret void | |
189 | |
190 define void @phi_another_pass() { | |
191 entry: | |
192 br label %next | |
193 | |
194 next: | |
195 %a = phi { { i64 } } [ undef, %entry ] | |
196 ret void | |
197 } | |
198 ; CHECK-LABEL: define void @phi_another_pass() | |
199 ; CHECK: %a.index.index = phi i64 [ undef, %entry ] | |
JF
2014/12/25 17:09:36
Same as select, please add a phi with { { i64, i64
Richard Diamond
2014/12/26 01:57:45
Done.
| |
200 ; CHECK-NEXT: ret void | |
OLD | NEW |