1 ; RUN: opt -S -codegenprepare -mtriple=amdgcn--amdhsa < %s | FileCheck %s
3 ; CHECK-LABEL: @no_sink_local_to_flat(
6 ; CHECK-NOT: addrspacecast
7 define i64 @no_sink_local_to_flat(i1 %pred, i64 addrspace(3)* %ptr) {
8 %ptr_cast = addrspacecast i64 addrspace(3)* %ptr to i64*
9 br i1 %pred, label %l1, label %l2
12 %v1 = load i64, i64 addrspace(3)* %ptr
16 %v2 = load i64, i64* %ptr_cast
20 ; CHECK-LABEL: @no_sink_private_to_flat(
21 ; CHECK: addrspacecast
23 ; CHECK-NOT: addrspacecast
24 define i64 @no_sink_private_to_flat(i1 %pred, i64 addrspace(5)* %ptr) {
25 %ptr_cast = addrspacecast i64 addrspace(5)* %ptr to i64*
26 br i1 %pred, label %l1, label %l2
29 %v1 = load i64, i64 addrspace(5)* %ptr
33 %v2 = load i64, i64* %ptr_cast
38 ; CHECK-LABEL: @sink_global_to_flat(
39 ; CHECK-NOT: addrspacecast
41 ; CHECK: addrspacecast
42 define i64 @sink_global_to_flat(i1 %pred, i64 addrspace(1)* %ptr) {
43 %ptr_cast = addrspacecast i64 addrspace(1)* %ptr to i64*
44 br i1 %pred, label %l1, label %l2
47 %v1 = load i64, i64 addrspace(1)* %ptr
51 %v2 = load i64, i64* %ptr_cast
55 ; CHECK-LABEL: @sink_flat_to_global(
56 ; CHECK-NOT: addrspacecast
58 ; CHECK: addrspacecast
59 define i64 @sink_flat_to_global(i1 %pred, i64* %ptr) {
60 %ptr_cast = addrspacecast i64* %ptr to i64 addrspace(1)*
61 br i1 %pred, label %l1, label %l2
64 %v1 = load i64, i64* %ptr
68 %v2 = load i64, i64 addrspace(1)* %ptr_cast
72 ; CHECK-LABEL: @sink_flat_to_constant(
73 ; CHECK-NOT: addrspacecast
75 ; CHECK: addrspacecast
76 define i64 @sink_flat_to_constant(i1 %pred, i64* %ptr) {
77 %ptr_cast = addrspacecast i64* %ptr to i64 addrspace(4)*
78 br i1 %pred, label %l1, label %l2
81 %v1 = load i64, i64* %ptr
85 %v2 = load i64, i64 addrspace(4)* %ptr_cast
89 ; CHECK-LABEL: @sink_flat_to_local(
90 ; CHECK-NOT: addrspacecast
92 ; CHECK: addrspacecast
93 define i64 @sink_flat_to_local(i1 %pred, i64* %ptr) {
94 %ptr_cast = addrspacecast i64* %ptr to i64 addrspace(3)*
95 br i1 %pred, label %l1, label %l2
98 %v1 = load i64, i64* %ptr
102 %v2 = load i64, i64 addrspace(3)* %ptr_cast
106 ; CHECK-LABEL: @sink_flat_to_private(
107 ; CHECK-NOT: addrspacecast
109 ; CHECK: addrspacecast
110 define i64 @sink_flat_to_private(i1 %pred, i64* %ptr) {
111 %ptr_cast = addrspacecast i64* %ptr to i64 addrspace(5)*
112 br i1 %pred, label %l1, label %l2
115 %v1 = load i64, i64* %ptr
119 %v2 = load i64, i64 addrspace(5)* %ptr_cast