1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -passes=infer-address-spaces -assume-default-is-flat-addrspace %s | FileCheck %s
4 define void @double_ascast(<4 x ptr addrspace(3)> %input) {
5 ; CHECK-LABEL: define void @double_ascast
6 ; CHECK-SAME: (<4 x ptr addrspace(3)> [[INPUT:%.*]]) {
8 ; CHECK-NEXT: call void @use(<4 x ptr addrspace(3)> [[INPUT]])
12 %tmp0 = addrspacecast <4 x ptr addrspace(3)> %input to <4 x ptr>
13 %tmp1 = addrspacecast <4 x ptr> %tmp0 to <4 x ptr addrspace(3)>
14 call void @use(<4 x ptr addrspace(3)> %tmp1)
18 define void @double_gep(ptr addrspace(3) %input, <4 x i64> %i, i64 %j) {
19 ; CHECK-LABEL: define void @double_gep
20 ; CHECK-SAME: (ptr addrspace(3) [[INPUT:%.*]], <4 x i64> [[I:%.*]], i64 [[J:%.*]]) {
22 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr float, ptr addrspace(3) [[INPUT]], <4 x i64> [[I]]
23 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr float, <4 x ptr addrspace(3)> [[TMP1]], i64 [[J]]
24 ; CHECK-NEXT: call void @use(<4 x ptr addrspace(3)> [[TMP2]])
25 ; CHECK-NEXT: ret void
28 %tmp0 = addrspacecast ptr addrspace(3) %input to ptr
29 %tmp1 = getelementptr float, ptr %tmp0, <4 x i64> %i
30 %tmp2 = getelementptr float, <4 x ptr> %tmp1, i64 %j
31 %tmp3 = addrspacecast <4 x ptr> %tmp2 to <4 x ptr addrspace(3)>
32 call void @use(<4 x ptr addrspace(3)> %tmp3)
36 define void @inferas_phi(<4 x ptr addrspace(3)> %input, i1 %cond) {
37 ; CHECK-LABEL: define void @inferas_phi
38 ; CHECK-SAME: (<4 x ptr addrspace(3)> [[INPUT:%.*]], i1 [[COND:%.*]]) {
40 ; CHECK-NEXT: br i1 [[COND]], label [[INC:%.*]], label [[END:%.*]]
42 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr float, <4 x ptr addrspace(3)> [[INPUT]], i64 1
43 ; CHECK-NEXT: br label [[END]]
45 ; CHECK-NEXT: [[TMP2:%.*]] = phi <4 x ptr addrspace(3)> [ [[INPUT]], [[ENTRY:%.*]] ], [ [[TMP1]], [[INC]] ]
46 ; CHECK-NEXT: call void @use(<4 x ptr addrspace(3)> [[TMP2]])
47 ; CHECK-NEXT: ret void
50 %tmp0 = addrspacecast <4 x ptr addrspace(3)> %input to <4 x ptr>
51 br i1 %cond, label %inc, label %end
54 %tmp1 = getelementptr float, <4 x ptr> %tmp0, i64 1
58 %tmp2 = phi <4 x ptr> [ %tmp0, %entry ], [ %tmp1, %inc ]
59 %tmp3 = addrspacecast <4 x ptr> %tmp2 to <4 x ptr addrspace(3)>
60 call void @use(<4 x ptr addrspace(3)> %tmp3)
64 define void @inferas_ptr2int2ptr(<4 x ptr addrspace(3)> %input) {
65 ; CHECK-LABEL: define void @inferas_ptr2int2ptr
66 ; CHECK-SAME: (<4 x ptr addrspace(3)> [[INPUT:%.*]]) {
68 ; CHECK-NEXT: call void @use(<4 x ptr addrspace(3)> [[INPUT]])
69 ; CHECK-NEXT: ret void
72 %tmp0 = addrspacecast <4 x ptr addrspace(3)> %input to <4 x ptr>
73 %tmp1 = ptrtoint <4 x ptr> %tmp0 to <4 x i64>
74 %tmp2 = inttoptr <4 x i64> %tmp1 to <4 x ptr>
75 %tmp3 = addrspacecast <4 x ptr> %tmp2 to <4 x ptr addrspace(3)>
76 call void @use(<4 x ptr addrspace(3)> %tmp3)
80 define void @inferas_loop(<4 x ptr addrspace(3)> %begin, <4 x ptr addrspace(3)> %end) {
81 ; CHECK-LABEL: define void @inferas_loop
82 ; CHECK-SAME: (<4 x ptr addrspace(3)> [[BEGIN:%.*]], <4 x ptr addrspace(3)> [[END:%.*]]) {
84 ; CHECK-NEXT: br label [[LOOP:%.*]]
86 ; CHECK-NEXT: [[NOW:%.*]] = phi <4 x ptr addrspace(3)> [ [[BEGIN]], [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
87 ; CHECK-NEXT: call void @use(<4 x ptr addrspace(3)> [[NOW]])
88 ; CHECK-NEXT: [[NEXT]] = getelementptr float, <4 x ptr addrspace(3)> [[NOW]], i64 1
89 ; CHECK-NEXT: [[VEQ:%.*]] = icmp eq <4 x ptr addrspace(3)> [[NEXT]], [[END]]
90 ; CHECK-NEXT: [[MASK:%.*]] = bitcast <4 x i1> [[VEQ]] to i4
91 ; CHECK-NEXT: [[COND:%.*]] = icmp eq i4 [[MASK]], 0
92 ; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
94 ; CHECK-NEXT: ret void
97 %begin0 = addrspacecast <4 x ptr addrspace(3)> %begin to <4 x ptr>
98 %end0 = addrspacecast <4 x ptr addrspace(3)> %end to <4 x ptr>
102 %now = phi <4 x ptr> [ %begin0, %entry ], [ %next, %loop ]
103 %now3 = addrspacecast <4 x ptr> %now to <4 x ptr addrspace(3)>
104 call void @use(<4 x ptr addrspace(3)> %now3)
105 %next = getelementptr float, <4 x ptr> %now, i64 1
106 %veq = icmp eq <4 x ptr> %next, %end0
107 %mask = bitcast <4 x i1> %veq to i4
108 %cond = icmp eq i4 %mask, 0
109 br i1 %cond, label %loop, label %exit
115 declare void @use(<4 x ptr addrspace(3)>)