xref: /llvm-project/llvm/test/Analysis/BasicAA/128-bit-ptr.ll (revision 303c308e452c703c3d47940383ded3b2d3eefd56)
1; This testcase consists of alias relations on 128-bit pointers that
2; should be completely resolvable by basicaa.
3
4; RUN: opt < %s -aa-pipeline=basic-aa -passes=aa-eval -print-no-aliases -print-may-aliases -print-must-aliases -disable-output 2>&1 | FileCheck %s
5
6target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-i128:128:128-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-p100:128:64:64-p101:128:64:64"
7
8
9; test0 is similar to SimpleCases.ll
10
11%T = type { i32, [10 x i8] }
12
13; CHECK:     Function: test0
14; CHECK-NOT:   MayAlias:
15define void @test0(ptr addrspace(100) %P) {
16  %C = getelementptr %T, ptr addrspace(100) %P, i64 0, i32 1
17  %D = getelementptr %T, ptr addrspace(100) %P, i64 0, i32 1, i64 0
18  %E = getelementptr %T, ptr addrspace(100) %P, i64 0, i32 1, i64 5
19  load %T, ptr addrspace(100) %P
20  load i32, ptr addrspace(100) %P
21  load [10 x i8], ptr addrspace(100) %C
22  load i8, ptr addrspace(100) %D
23  load i8, ptr addrspace(100) %E
24  ret void
25}
26
27; test1 checks that >64 bits of index can be considered.
28; If BasicAA is truncating the arithmetic, it will conclude
29; that %A and %B must alias when in fact they must not.
30
31; CHECK:     Function: test1
32; CHECK-NOT:   MustAlias:
33; CHECK:       NoAlias:
34; CHECK-SAME:  %A
35; CHECK-SAME:  %B
36define void @test1(ptr addrspace(100) %P, i128 %i) {
37  ; 1180591620717411303424 is 2**70
38  ;  590295810358705651712 is 2**69
39  %i70 = add i128 %i, 1180591620717411303424
40  %i69 = add i128 %i, 590295810358705651712
41  %A = getelementptr double, ptr addrspace(100) %P, i128 %i70
42  %B = getelementptr double, ptr addrspace(100) %P, i128 %i69
43  load double, ptr addrspace(100) %A
44  load double, ptr addrspace(100) %B
45  ret void
46}
47
48; test2 checks that >64 bits of index can be considered
49; and computes the same address in two ways to ensure that
50; they are considered equivalent.
51
52; CHECK: Function: test2
53; CHECK: MustAlias:
54; CHECK-SAME: %A
55; CHECK-SAME: %C
56define void @test2(ptr addrspace(100) %P, i128 %i) {
57  ; 1180591620717411303424 is 2**70
58  ;  590295810358705651712 is 2**69
59  %i70 = add i128 %i, 1180591620717411303424
60  %i69 = add i128 %i, 590295810358705651712
61  %j70 = add i128 %i69, 590295810358705651712
62  %A = getelementptr double, ptr addrspace(100) %P, i128 %i70
63  %C = getelementptr double, ptr addrspace(100) %P, i128 %j70
64  load double, ptr addrspace(100) %A
65  load double, ptr addrspace(100) %C
66  ret void
67}
68