1 ; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -o - -passes=infer-address-spaces %s | FileCheck -check-prefixes=COMMON,AMDGCN %s
2 ; RUN: opt -S -o - -passes=infer-address-spaces -assume-default-is-flat-addrspace %s | FileCheck -check-prefixes=COMMON,NOTTI %s
4 target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7:8"
6 ; COMMON-LABEL: @noop_ptrint_pair(
7 ; AMDGCN-NEXT: store i32 0, ptr addrspace(1) %{{.*}}
8 ; AMDGCN-NEXT: ret void
9 ; NOTTI-NEXT: %1 = ptrtoint ptr addrspace(1) %x.coerce to i64
10 ; NOTTI-NEXT: %2 = inttoptr i64 %1 to ptr
11 ; NOTTI-NEXT: store i32 0, ptr %2
12 ; NOTTI-NEXT: ret void
13 define void @noop_ptrint_pair(ptr addrspace(1) %x.coerce) {
14 %1 = ptrtoint ptr addrspace(1) %x.coerce to i64
15 %2 = inttoptr i64 %1 to ptr
20 ; COMMON-LABEL: @non_noop_ptrint_pair(
21 ; AMDGCN-NEXT: ptrtoint ptr addrspace(3) %{{.*}} to i64
22 ; AMDGCN-NEXT: inttoptr i64 %{{.*}} to ptr
23 ; AMDGCN-NEXT: store i32 0, ptr %{{.*}}
24 ; AMDGCN-NEXT: ret void
25 ; NOTTI-NEXT: ptrtoint ptr addrspace(3) %{{.*}} to i64
26 ; NOTTI-NEXT: inttoptr i64 %{{.*}} to ptr
27 ; NOTTI-NEXT: store i32 0, ptr %{{.*}}
28 ; NOTTI-NEXT: ret void
29 define void @non_noop_ptrint_pair(ptr addrspace(3) %x.coerce) {
30 %1 = ptrtoint ptr addrspace(3) %x.coerce to i64
31 %2 = inttoptr i64 %1 to ptr
36 ; COMMON-LABEL: @non_noop_ptrint_pair2(
37 ; AMDGCN-NEXT: ptrtoint ptr addrspace(1) %{{.*}} to i32
38 ; AMDGCN-NEXT: inttoptr i32 %{{.*}} to ptr
39 ; AMDGCN-NEXT: store i32 0, ptr %{{.*}}
40 ; AMDGCN-NEXT: ret void
41 ; NOTTI-NEXT: ptrtoint ptr addrspace(1) %{{.*}} to i32
42 ; NOTTI-NEXT: inttoptr i32 %{{.*}} to ptr
43 ; NOTTI-NEXT: store i32 0, ptr %{{.*}}
44 ; NOTTI-NEXT: ret void
45 define void @non_noop_ptrint_pair2(ptr addrspace(1) %x.coerce) {
46 %1 = ptrtoint ptr addrspace(1) %x.coerce to i32
47 %2 = inttoptr i32 %1 to ptr
52 @g = addrspace(1) global i32 0, align 4
53 @l = addrspace(3) global i32 0, align 4
55 ; COMMON-LABEL: @noop_ptrint_pair_ce(
56 ; AMDGCN-NEXT: store i32 0, ptr addrspace(1) @g
57 ; AMDGCN-NEXT: ret void
58 ; NOTTI-NEXT: store i32 0, ptr inttoptr (i64 ptrtoint (ptr addrspace(1) @g to i64) to ptr)
59 ; NOTTI-NEXT: ret void
60 define void @noop_ptrint_pair_ce() {
61 store i32 0, ptr inttoptr (i64 ptrtoint (ptr addrspace(1) @g to i64) to ptr)
65 ; COMMON-LABEL: @noop_ptrint_pair_ce2(
66 ; AMDGCN-NEXT: ret ptr addrspacecast (ptr addrspace(1) @g to ptr)
67 ; NOTTI-NEXT: ret ptr inttoptr (i64 ptrtoint (ptr addrspace(1) @g to i64) to ptr)
68 define ptr @noop_ptrint_pair_ce2() {
69 ret ptr inttoptr (i64 ptrtoint (ptr addrspace(1) @g to i64) to ptr)
72 ; COMMON-LABEL: @noop_ptrint_pair_ce2_vec(
73 ; AMDGCN-NEXT: ret <2 x ptr> <ptr inttoptr (i64 ptrtoint (ptr addrspace(1) @g to i64) to ptr), ptr inttoptr (i64 ptrtoint (ptr addrspace(3) @l to i64) to ptr)>
74 ; NOTTI-NEXT: ret <2 x ptr> <ptr inttoptr (i64 ptrtoint (ptr addrspace(1) @g to i64) to ptr), ptr inttoptr (i64 ptrtoint (ptr addrspace(3) @l to i64) to ptr)>
75 define <2 x ptr> @noop_ptrint_pair_ce2_vec() {
76 ret <2 x ptr> <ptr inttoptr (i64 ptrtoint (ptr addrspace(1) @g to i64) to ptr), ptr inttoptr (i64 ptrtoint (ptr addrspace(3) @l to i64) to ptr)>
79 ; COMMON-LABEL: @noop_ptrint_pair_ce3(
80 ; AMDGCN-NEXT: %i = inttoptr i64 ptrtoint (ptr addrspace(1) @g to i64) to ptr
81 ; AMDGCN-NEXT: ret void
82 ; NOTTI-NEXT: %i = inttoptr i64 ptrtoint (ptr addrspace(1) @g to i64) to ptr
83 ; NOTTI-NEXT: ret void
84 define void @noop_ptrint_pair_ce3() {
85 %i = inttoptr i64 ptrtoint (ptr addrspace(1) @g to i64) to ptr
89 ; COMMON-LABEL: @non_noop_ptrint_pair_ce(
90 ; AMDGCN-NEXT: store i32 0, ptr inttoptr (i64 ptrtoint (ptr addrspace(3) @l to i64) to ptr)
91 ; AMDGCN-NEXT: ret void
92 ; NOTTI-NEXT: store i32 0, ptr inttoptr (i64 ptrtoint (ptr addrspace(3) @l to i64) to ptr)
93 ; NOTTI-NEXT: ret void
94 define void @non_noop_ptrint_pair_ce() {
95 store i32 0, ptr inttoptr (i64 ptrtoint (ptr addrspace(3) @l to i64) to ptr)
99 ; COMMON-LABEL: @non_noop_ptrint_pair_ce2(
100 ; AMDGCN-NEXT: ret ptr inttoptr (i64 ptrtoint (ptr addrspace(3) @l to i64) to ptr)
101 ; NOTTI-NEXT: ret ptr inttoptr (i64 ptrtoint (ptr addrspace(3) @l to i64) to ptr)
102 define ptr @non_noop_ptrint_pair_ce2() {
103 ret ptr inttoptr (i64 ptrtoint (ptr addrspace(3) @l to i64) to ptr)
106 ; COMMON-LABEL: @non_noop_ptrint_pair_ce3(
107 ; AMDGCN-NEXT: ret ptr inttoptr (i32 ptrtoint (ptr addrspace(1) @g to i32) to ptr)
108 ; NOTTI-NEXT: ret ptr inttoptr (i32 ptrtoint (ptr addrspace(1) @g to i32) to ptr)
109 define ptr @non_noop_ptrint_pair_ce3() {
110 ret ptr inttoptr (i32 ptrtoint (ptr addrspace(1) @g to i32) to ptr)
113 ; COMMON-LABEL: @non_noop_ptrint_pair_ce4(
114 ; AMDGCN-NEXT: ret ptr inttoptr (i128 ptrtoint (ptr addrspace(3) @l to i128) to ptr)
115 ; NOTTI-NEXT: ret ptr inttoptr (i128 ptrtoint (ptr addrspace(3) @l to i128) to ptr)
116 define ptr @non_noop_ptrint_pair_ce4() {
117 ret ptr inttoptr (i128 ptrtoint (ptr addrspace(3) @l to i128) to ptr)