@@ -132,3 +132,61 @@ define i64 @test14(i64 %a) nounwind {
132
132
ret i64 %2
133
133
}
134
134
135
+ ; Check that we hoist the absolute address of the stores to the entry block.
136
+ define void @test17 (ptr %s , i32 %size ) nounwind {
137
+ ; CHECK-LABEL: test17
138
+ ; CHECK: %const = bitcast i32 -1073741792 to i32
139
+ ; CHECK: %0 = inttoptr i32 %const to ptr
140
+ ; CHECK: store i32 20, ptr %0
141
+ ; CHECK: %1 = inttoptr i32 %const to ptr
142
+ ; CHECK: store i32 10, ptr %1
143
+ entry:
144
+ %cond = icmp eq i32 %size , 0
145
+ br i1 %cond , label %if.true , label %exit
146
+ if.true:
147
+ store i32 20 , ptr inttoptr (i32 -1073741792 to ptr )
148
+ br label %exit
149
+ exit:
150
+ store i32 10 , ptr inttoptr (i32 -1073741792 to ptr )
151
+ ret void
152
+ }
153
+
154
+ ; Check that we hoist the absolute address of the loads to the entry block.
155
+ define i32 @test18 (ptr %s , i32 %size ) nounwind {
156
+ ; CHECK-LABEL: test18
157
+ ; CHECK: %const = bitcast i32 -1073741792 to i32
158
+ ; CHECK: %0 = inttoptr i32 %const to ptr
159
+ ; CHECK: %1 = load i32, ptr %0
160
+ ; CHECK: %2 = inttoptr i32 %const to ptr
161
+ ; CHECK: %3 = load i32, ptr %2
162
+ entry:
163
+ %cond = icmp eq i32 %size , 0
164
+ br i1 %cond , label %if.true , label %if.false
165
+ if.true:
166
+ %0 = load i32 , ptr inttoptr (i32 -1073741792 to ptr )
167
+ br label %return
168
+ if.false:
169
+ %1 = load i32 , ptr inttoptr (i32 -1073741792 to ptr )
170
+ br label %return
171
+ return:
172
+ %val = phi i32 [%0 , %if.true ], [%1 , %if.false ]
173
+ ret i32 %val
174
+ }
175
+
176
+
177
+ ; For addresses between [0, 2048), we can use ld/sd xN, address(zero), so don't
178
+ ; hoist.
179
+ define void @test19 (ptr %s , i32 %size ) nounwind {
180
+ ; CHECK-LABEL: test19
181
+ ; CHECK: store i32 20, ptr inttoptr (i32 2044 to ptr)
182
+ ; CHECK: store i32 10, ptr inttoptr (i32 2044 to ptr)
183
+ entry:
184
+ %cond = icmp eq i32 %size , 0
185
+ br i1 %cond , label %if.true , label %exit
186
+ if.true:
187
+ store i32 20 , ptr inttoptr (i32 2044 to ptr )
188
+ br label %exit
189
+ exit:
190
+ store i32 10 , ptr inttoptr (i32 2044 to ptr )
191
+ ret void
192
+ }
0 commit comments