1 ; RUN: opt -passes=aa-eval -aa-pipeline=nvptx-aa -print-all-alias-modref-info < %s -S 2>&1 \
2 ; RUN: | FileCheck %s --check-prefixes CHECK-ALIAS
4 ; RUN: opt -aa-pipeline=nvptx-aa -passes=licm < %s -S | FileCheck %s --check-prefixes CHECK-AA-CONST
5 ; RUN: opt -aa-pipeline=basic-aa -passes=licm < %s -S | FileCheck %s --check-prefixes CHECK-NOAA-CONST
7 target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
8 target triple = "nvptx64-nvidia-cuda"
10 ; CHECK-ALIAS-LABEL: Function: test
11 ; CHECK-ALIAS: MayAlias: i8* %gen, i8 addrspace(1)* %global
12 ; CHECK-ALIAS: MayAlias: i8* %gen, i8 addrspace(3)* %shared
13 ; CHECK-ALIAS: NoAlias: i8 addrspace(1)* %global, i8 addrspace(3)* %shared
14 ; CHECK-ALIAS: MayAlias: i8 addrspace(4)* %const, i8* %gen
15 ; CHECK-ALIAS: NoAlias: i8 addrspace(4)* %const, i8 addrspace(1)* %global
16 ; CHECK-ALIAS: NoAlias: i8 addrspace(4)* %const, i8 addrspace(3)* %shared
17 ; CHECK-ALIAS: MayAlias: i8* %gen, i8 addrspace(5)* %local
18 ; CHECK-ALIAS: NoAlias: i8 addrspace(1)* %global, i8 addrspace(5)* %local
19 ; CHECK-ALIAS: NoAlias: i8 addrspace(5)* %local, i8 addrspace(3)* %shared
20 ; CHECK-ALIAS: NoAlias: i8 addrspace(4)* %const, i8 addrspace(5)* %local
21 ; CHECK-ALIAS: MayAlias: i8* %gen, i8 addrspace(101)* %param
22 ; CHECK-ALIAS: NoAlias: i8 addrspace(1)* %global, i8 addrspace(101)* %param
23 ; CHECK-ALIAS: NoAlias: i8 addrspace(101)* %param, i8 addrspace(3)* %shared
24 ; CHECK-ALIAS: NoAlias: i8 addrspace(4)* %const, i8 addrspace(101)* %param
25 ; CHECK-ALIAS: NoAlias: i8 addrspace(5)* %local, i8 addrspace(101)* %param
27 define i8 @test_alias(ptr %gen, ptr addrspace(1) %global, ptr addrspace(3) %shared, ptr addrspace(4) %const, ptr addrspace(5) %local) {
28 %param = addrspacecast ptr %gen to ptr addrspace(101)
29 %v1 = load i8, ptr %gen
30 %v2 = load i8, ptr addrspace(1) %global
31 %v3 = load i8, ptr addrspace(3) %shared
32 %v4 = load i8, ptr addrspace(4) %const
33 %v5 = load i8, ptr addrspace(5) %local
34 %v6 = load i8, ptr addrspace(101) %param
35 %res1 = add i8 %v1, %v2
36 %res2 = add i8 %res1, %v3
37 %res3 = add i8 %res2, %v4
38 %res4 = add i8 %res3, %v5
39 %res5 = add i8 %res4, %v6
43 ; CHECK-ALIAS-LABEL: Function: test_const
44 ; CHECK-ALIAS: MayAlias: i8* %gen, i8 addrspace(1)* %global
45 ; CHECK-ALIAS: NoAlias: i8 addrspace(4)* %const, i8 addrspace(1)* %global
46 ; CHECK-ALIAS: MayAlias: i8 addrspace(4)* %const, i8* %gen
48 define i8 @test_const(ptr %gen, ptr addrspace(1) %global, ptr addrspace(4) %const) {
50 ; Even though %gen and %const may alias and there is a store to %gen,
51 ; LICM should be able to hoist %load_const because it is known to be
52 ; constant (AA::pointsToConstantMemory()).
54 ; CHECK-AA-CONST-LABEL: @test_const
55 ; CHECK-AA-CONST-LABEL: entry
56 ; CHECK-AA-CONST: %[[LOAD_CONST:.+]] = load i8, ptr addrspace(4)
57 ; CHECK-AA-CONST-LABEL: loop
58 ; CHECK-AA-CONST: add {{.*}}%[[LOAD_CONST]]
60 ; Without NVPTX AA the load is left in the loop because we assume that
61 ; it may be clobbered by the store.
63 ; CHECK-NOAA-CONST-LABEL: @test_const
64 ; CHECK-NOAA-CONST-LABEL: loop
65 ; CHECK-NOAA-CONST: %[[LOAD_CONST:.+]] = load i8, ptr addrspace(4)
66 ; CHECK-NOAA-CONST: add {{.*}}%[[LOAD_CONST]]
70 %v = phi i8 [0, %entry], [%v2, %loop]
71 %load_global = load i8, ptr addrspace(1) %global
72 store i8 %load_global, ptr %gen
73 %load_const = load i8, ptr addrspace(4) %const
74 %v2 = add i8 %v, %load_const
75 %cond = icmp eq i8 %load_const, 0
76 br i1 %cond, label %done, label %loop
81 ; Same as @test_const above, but for param space.
83 ; CHECK-ALIAS-LABEL: Function: test_param
84 ; CHECK-ALIAS: MayAlias: i8* %gen, i8 addrspace(1)* %global
85 ; CHECK-ALIAS: NoAlias: i8 addrspace(1)* %global, i8 addrspace(101)* %param
86 ; CHECK-ALIAS: MayAlias: i8* %gen, i8 addrspace(101)* %param
88 define i8 @test_param(ptr %gen, ptr addrspace(1) %global, ptr %param_gen) {
90 ; CHECK-AA-CONST-LABEL: @test_param
91 ; CHECK-AA-CONST-LABEL: entry
92 ; CHECK-AA-CONST: %[[LOAD_PARAM:.+]] = load i8, ptr addrspace(101)
93 ; CHECK-AA-CONST-LABEL: loop
94 ; CHECK-AA-CONST: add {{.*}}%[[LOAD_PARAM]]
96 ; CHECK-NOAA-CONST-LABEL: @test_param
97 ; CHECK-NOAA-CONST-LABEL: loop
98 ; CHECK-NOAA-CONST: %[[LOAD_PARAM:.+]] = load i8, ptr addrspace(101)
99 ; CHECK-NOAA-CONST: add {{.*}}%[[LOAD_PARAM]]
101 %param = addrspacecast ptr %param_gen to ptr addrspace(101)
104 %v = phi i8 [0, %entry], [%v2, %loop]
105 %load_global = load i8, ptr addrspace(1) %global
106 store i8 %load_global, ptr %gen
107 %load_const = load i8, ptr addrspace(101) %param
108 %v2 = add i8 %v, %load_const
109 %cond = icmp eq i8 %load_const, 0
110 br i1 %cond, label %done, label %loop