@@ -150,3 +150,61 @@ define i64 @test16(i64 %a) nounwind {
150
150
ret i64 %2
151
151
}
152
152
153
+ ; Check that we hoist the absolute address of the stores to the entry block.
154
+ define void @test17 (ptr %s , i32 %size ) nounwind {
155
+ ; CHECK-LABEL: test17
156
+ ; CHECK: %const = bitcast i32 -1073741792 to i32
157
+ ; CHECK: %0 = inttoptr i32 %const to ptr
158
+ ; CHECK: store i32 20, ptr %0
159
+ ; CHECK: %1 = inttoptr i32 %const to ptr
160
+ ; CHECK: store i32 10, ptr %1
161
+ entry:
162
+ %cond = icmp eq i32 %size , 0
163
+ br i1 %cond , label %if.true , label %exit
164
+ if.true:
165
+ store i32 20 , ptr inttoptr (i32 -1073741792 to ptr )
166
+ br label %exit
167
+ exit:
168
+ store i32 10 , ptr inttoptr (i32 -1073741792 to ptr )
169
+ ret void
170
+ }
171
+
172
+ ; Check that we hoist the absolute address of the loads to the entry block.
173
+ define i32 @test18 (ptr %s , i32 %size ) nounwind {
174
+ ; CHECK-LABEL: test18
175
+ ; CHECK: %const = bitcast i32 -1073741792 to i32
176
+ ; CHECK: %0 = inttoptr i32 %const to ptr
177
+ ; CHECK: %1 = load i32, ptr %0
178
+ ; CHECK: %2 = inttoptr i32 %const to ptr
179
+ ; CHECK: %3 = load i32, ptr %2
180
+ entry:
181
+ %cond = icmp eq i32 %size , 0
182
+ br i1 %cond , label %if.true , label %if.false
183
+ if.true:
184
+ %0 = load i32 , ptr inttoptr (i32 -1073741792 to ptr )
185
+ br label %return
186
+ if.false:
187
+ %1 = load i32 , ptr inttoptr (i32 -1073741792 to ptr )
188
+ br label %return
189
+ return:
190
+ %val = phi i32 [%0 , %if.true ], [%1 , %if.false ]
191
+ ret i32 %val
192
+ }
193
+
194
+
195
+ ; For addresses between [0, 2048), we can use ld/sd xN, address(zero), so don't
196
+ ; hoist.
197
+ define void @test19 (ptr %s , i32 %size ) nounwind {
198
+ ; CHECK-LABEL: test19
199
+ ; CHECK: store i32 20, ptr inttoptr (i32 2044 to ptr)
200
+ ; CHECK: store i32 10, ptr inttoptr (i32 2044 to ptr)
201
+ entry:
202
+ %cond = icmp eq i32 %size , 0
203
+ br i1 %cond , label %if.true , label %exit
204
+ if.true:
205
+ store i32 20 , ptr inttoptr (i32 2044 to ptr )
206
+ br label %exit
207
+ exit:
208
+ store i32 10 , ptr inttoptr (i32 2044 to ptr )
209
+ ret void
210
+ }
0 commit comments