1; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
2target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
3target triple = "x86_64-unknown-linux-gnu"
4
5; CHECK-LABEL: test_with_zext
6; CHECK:  NoAlias: i8* %a, i8* %b
7
8define void @test_with_zext() {
9  %1 = tail call i8* @malloc(i64 120)
10  %a = getelementptr inbounds i8* %1, i64 8
11  %2 = getelementptr inbounds i8* %1, i64 16
12  %3 = zext i32 3 to i64
13  %b = getelementptr inbounds i8* %2, i64 %3
14  ret void
15}
16
17; CHECK-LABEL: test_with_lshr
18; CHECK:  NoAlias: i8* %a, i8* %b
19
20define void @test_with_lshr(i64 %i) {
21  %1 = tail call i8* @malloc(i64 120)
22  %a = getelementptr inbounds i8* %1, i64 8
23  %2 = getelementptr inbounds i8* %1, i64 16
24  %3 = lshr i64 %i, 2
25  %b = getelementptr inbounds i8* %2, i64 %3
26  ret void
27}
28
29; CHECK-LABEL: test_with_a_loop
30; CHECK:  NoAlias: i8* %a, i8* %b
31
32define void @test_with_a_loop() {
33  %1 = tail call i8* @malloc(i64 120)
34  %a = getelementptr inbounds i8* %1, i64 8
35  %2 = getelementptr inbounds i8* %1, i64 16
36  br label %for.loop
37
38for.loop:
39  %i = phi i32 [ 0, %0 ], [ %i.next, %for.loop ]
40  %3 = zext i32 %i to i64
41  %b = getelementptr inbounds i8* %2, i64 %3
42  %i.next = add nuw nsw i32 %i, 1
43  %4 = icmp eq i32 %i.next, 10
44  br i1 %4, label %for.loop.exit, label %for.loop
45
46for.loop.exit:
47  ret void
48}
49
50; CHECK-LABEL: test_sign_extension
51; CHECK:  PartialAlias: i64* %b.i64, i8* %a
52
53define void @test_sign_extension(i32 %p) {
54  %1 = tail call i8* @malloc(i64 120)
55  %p.64 = zext i32 %p to i64
56  %a = getelementptr inbounds i8* %1, i64 %p.64
57  %p.minus1 = add i32 %p, -1
58  %p.minus1.64 = zext i32 %p.minus1 to i64
59  %b.i8 = getelementptr inbounds i8* %1, i64 %p.minus1.64
60  %b.i64 = bitcast i8* %b.i8 to i64*
61  ret void
62}
63
64; Function Attrs: nounwind
65declare noalias i8* @malloc(i64)
66