1 ; RUN: opt -S -codegenprepare -mtriple=amdgcn-unknown-unknown -mcpu=bonaire < %s | FileCheck -check-prefix=OPT -check-prefix=OPT-CI %s
2 ; RUN: opt -S -codegenprepare -mtriple=amdgcn-unknown-unknown -mcpu=tonga < %s | FileCheck -check-prefix=OPT -check-prefix=OPT-VI %s
3 ; RUN: llc -march=amdgcn -mcpu=bonaire -mattr=-promote-alloca < %s | FileCheck -check-prefix=GCN -check-prefix=CI %s
4 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-promote-alloca < %s | FileCheck -check-prefix=GCN -check-prefix=VI %s
6 ; OPT-LABEL: @test_no_sink_flat_small_offset_i32(
7 ; OPT: getelementptr i32, i32 addrspace(4)* %in
11 ; GCN-LABEL: {{^}}test_no_sink_flat_small_offset_i32:
12 ; GCN: flat_load_dword
14 define void @test_no_sink_flat_small_offset_i32(i32 addrspace(4)* %out, i32 addrspace(4)* %in, i32 %cond) {
16 %out.gep = getelementptr i32, i32 addrspace(4)* %out, i64 999999
17 %in.gep = getelementptr i32, i32 addrspace(4)* %in, i64 7
18 %tmp0 = icmp eq i32 %cond, 0
19 br i1 %tmp0, label %endif, label %if
22 %tmp1 = load i32, i32 addrspace(4)* %in.gep
26 %x = phi i32 [ %tmp1, %if ], [ 0, %entry ]
27 store i32 %x, i32 addrspace(4)* %out.gep
34 ; OPT-LABEL: @test_sink_noop_addrspacecast_flat_to_global_i32(
35 ; OPT: getelementptr i32, i32 addrspace(4)* %out,
36 ; OPT-CI-NOT: getelementptr
44 ; GCN-LABEL: {{^}}test_sink_noop_addrspacecast_flat_to_global_i32:
45 ; CI: buffer_load_dword {{v[0-9]+}}, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:28
46 define void @test_sink_noop_addrspacecast_flat_to_global_i32(i32 addrspace(4)* %out, i32 addrspace(4)* %in, i32 %cond) {
48 %out.gep = getelementptr i32, i32 addrspace(4)* %out, i64 999999
49 %in.gep = getelementptr i32, i32 addrspace(4)* %in, i64 7
50 %cast = addrspacecast i32 addrspace(4)* %in.gep to i32 addrspace(1)*
51 %tmp0 = icmp eq i32 %cond, 0
52 br i1 %tmp0, label %endif, label %if
55 %tmp1 = load i32, i32 addrspace(1)* %cast
59 %x = phi i32 [ %tmp1, %if ], [ 0, %entry ]
60 store i32 %x, i32 addrspace(4)* %out.gep
67 ; OPT-LABEL: @test_sink_noop_addrspacecast_flat_to_constant_i32(
68 ; OPT: getelementptr i32, i32 addrspace(4)* %out,
69 ; OPT-CI-NOT: getelementptr
77 ; GCN-LABEL: {{^}}test_sink_noop_addrspacecast_flat_to_constant_i32:
78 ; CI: s_load_dword {{s[0-9]+}}, s{{\[[0-9]+:[0-9]+\]}}, 0xd
79 define void @test_sink_noop_addrspacecast_flat_to_constant_i32(i32 addrspace(4)* %out, i32 addrspace(4)* %in, i32 %cond) {
81 %out.gep = getelementptr i32, i32 addrspace(4)* %out, i64 999999
82 %in.gep = getelementptr i32, i32 addrspace(4)* %in, i64 7
83 %cast = addrspacecast i32 addrspace(4)* %in.gep to i32 addrspace(2)*
84 %tmp0 = icmp eq i32 %cond, 0
85 br i1 %tmp0, label %endif, label %if
88 %tmp1 = load i32, i32 addrspace(2)* %cast
92 %x = phi i32 [ %tmp1, %if ], [ 0, %entry ]
93 store i32 %x, i32 addrspace(4)* %out.gep