llvm.org GIT mirror llvm / 0f33e74
[BasicAA] Add a test for PR24468 to be sure we won't regress when we finally get the GEP aliasing right. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245395 91177308-0d34-0410-b5e6-96231b3b80d8 Quentin Colombet 4 years ago
1 changed file(s) with 48 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
227227 ; CHECK-LABEL: @test12(
228228 ; CHECK: ret i32 %r
229229 }
230
231 @P = internal global i32 715827882, align 4
232 @Q = internal global i32 715827883, align 4
233 @.str = private unnamed_addr constant [7 x i8] c"%u %u\0A\00", align 1
234
235 ; Make sure we recognize that u[0] and u[Global + Cst] may alias
236 ; when the addition has wrapping semantic.
237 ; PR24468.
238 ; CHECK-LABEL: @test13(
239 ; Make sure the stores appear before the related loads.
240 ; CHECK: store i8 42,
241 ; CHECK: store i8 99,
242 ; Find the loads and make sure they are used in the arguments to the printf.
243 ; CHECK: [[T0ADDR:%[a-zA-Z0-9_]+]] = getelementptr inbounds [3 x i8], [3 x i8]* %t, i32 0, i32 0
244 ; CHECK: [[T0:%[a-zA-Z0-9_]+]] = load i8, i8* [[T0ADDR]], align 1
245 ; CHECK: [[T0ARG:%[a-zA-Z0-9_]+]] = zext i8 [[T0]] to i32
246 ; CHECK: [[U0ADDR:%[a-zA-Z0-9_]+]] = getelementptr inbounds [3 x i8], [3 x i8]* %u, i32 0, i32 0
247 ; CHECK: [[U0:%[a-zA-Z0-9_]+]] = load i8, i8* [[U0ADDR]], align 1
248 ; CHECK: [[U0ARG:%[a-zA-Z0-9_]+]] = zext i8 [[U0]] to i32
249 ; CHECK: call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i32 [[T0ARG]], i32 [[U0ARG]])
250 ; CHECK: ret
251 define void @test13() {
252 entry:
253 %t = alloca [3 x i8], align 1
254 %u = alloca [3 x i8], align 1
255 %tmp = load i32, i32* @P, align 4
256 %tmp1 = mul i32 %tmp, 3
257 %mul = add i32 %tmp1, -2147483646
258 %idxprom = zext i32 %mul to i64
259 %arrayidx = getelementptr inbounds [3 x i8], [3 x i8]* %t, i64 0, i64 %idxprom
260 store i8 42, i8* %arrayidx, align 1
261 %tmp2 = load i32, i32* @Q, align 4
262 %tmp3 = mul i32 %tmp2, 3
263 %mul2 = add i32 %tmp3, 2147483647
264 %idxprom3 = zext i32 %mul2 to i64
265 %arrayidx4 = getelementptr inbounds [3 x i8], [3 x i8]* %u, i64 0, i64 %idxprom3
266 store i8 99, i8* %arrayidx4, align 1
267 %arrayidx5 = getelementptr inbounds [3 x i8], [3 x i8]* %t, i64 0, i64 0
268 %tmp4 = load i8, i8* %arrayidx5, align 1
269 %conv = zext i8 %tmp4 to i32
270 %arrayidx6 = getelementptr inbounds [3 x i8], [3 x i8]* %u, i64 0, i64 0
271 %tmp5 = load i8, i8* %arrayidx6, align 1
272 %conv7 = zext i8 %tmp5 to i32
273 %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %conv, i32 %conv7)
274 ret void
275 }
276
277 declare i32 @printf(i8*, ...)