1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=atomic-expand %s | FileCheck %s
4 ; Make sure atomic loads are not bitcasted and lose metadata
6 define float @load_atomic_f32_global_system(ptr addrspace(1) %ptr) {
7 ; CHECK-LABEL: define float @load_atomic_f32_global_system(
8 ; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]]) {
9 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic float, ptr addrspace(1) [[PTR]] seq_cst, align 4, !some.unknown.md [[META0:![0-9]+]]
10 ; CHECK-NEXT: ret float [[TMP2]]
12 %ld = load atomic float, ptr addrspace(1) %ptr seq_cst, align 4, !some.unknown.md !0
16 define float @load_atomic_f32_global_agent(ptr addrspace(1) %ptr) {
17 ; CHECK-LABEL: define float @load_atomic_f32_global_agent(
18 ; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]]) {
19 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic float, ptr addrspace(1) [[PTR]] syncscope("agent") seq_cst, align 4, !some.unknown.md [[META0]]
20 ; CHECK-NEXT: ret float [[TMP2]]
22 %ld = load atomic float, ptr addrspace(1) %ptr syncscope("agent") seq_cst, align 4, !some.unknown.md !0
26 define float @load_atomic_f32_local(ptr addrspace(3) %ptr) {
27 ; CHECK-LABEL: define float @load_atomic_f32_local(
28 ; CHECK-SAME: ptr addrspace(3) [[PTR:%.*]]) {
29 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic float, ptr addrspace(3) [[PTR]] seq_cst, align 4, !some.unknown.md [[META0]]
30 ; CHECK-NEXT: ret float [[TMP2]]
32 %ld = load atomic float, ptr addrspace(3) %ptr seq_cst, align 4, !some.unknown.md !0
36 define float @load_atomic_f32_flat_system(ptr %ptr) {
37 ; CHECK-LABEL: define float @load_atomic_f32_flat_system(
38 ; CHECK-SAME: ptr [[PTR:%.*]]) {
39 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic float, ptr [[PTR]] seq_cst, align 4, !some.unknown.md [[META0]]
40 ; CHECK-NEXT: ret float [[TMP2]]
42 %ld = load atomic float, ptr %ptr seq_cst, align 4, !some.unknown.md !0
46 define float @load_atomic_f32_flat_agent(ptr %ptr) {
47 ; CHECK-LABEL: define float @load_atomic_f32_flat_agent(
48 ; CHECK-SAME: ptr [[PTR:%.*]]) {
49 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic float, ptr [[PTR]] syncscope("agent") seq_cst, align 4, !some.unknown.md [[META0]]
50 ; CHECK-NEXT: ret float [[TMP2]]
52 %ld = load atomic float, ptr %ptr syncscope("agent") seq_cst, align 4, !some.unknown.md !0
56 define half @load_atomic_f16_global_system(ptr addrspace(1) %ptr) {
57 ; CHECK-LABEL: define half @load_atomic_f16_global_system(
58 ; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]]) {
59 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic half, ptr addrspace(1) [[PTR]] seq_cst, align 4, !some.unknown.md [[META0]]
60 ; CHECK-NEXT: ret half [[TMP2]]
62 %ld = load atomic half, ptr addrspace(1) %ptr seq_cst, align 4, !some.unknown.md !0
66 define half @load_atomic_f16_global_agent(ptr addrspace(1) %ptr) {
67 ; CHECK-LABEL: define half @load_atomic_f16_global_agent(
68 ; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]]) {
69 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic half, ptr addrspace(1) [[PTR]] syncscope("agent") seq_cst, align 4, !some.unknown.md [[META0]]
70 ; CHECK-NEXT: ret half [[TMP2]]
72 %ld = load atomic half, ptr addrspace(1) %ptr syncscope("agent") seq_cst, align 4, !some.unknown.md !0
76 define half @load_atomic_f16_local(ptr addrspace(3) %ptr) {
77 ; CHECK-LABEL: define half @load_atomic_f16_local(
78 ; CHECK-SAME: ptr addrspace(3) [[PTR:%.*]]) {
79 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic half, ptr addrspace(3) [[PTR]] seq_cst, align 2, !some.unknown.md [[META0]]
80 ; CHECK-NEXT: ret half [[TMP2]]
82 %ld = load atomic half, ptr addrspace(3) %ptr seq_cst, align 2, !some.unknown.md !0
86 define bfloat @load_atomic_bf16_global_system(ptr addrspace(1) %ptr) {
87 ; CHECK-LABEL: define bfloat @load_atomic_bf16_global_system(
88 ; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]]) {
89 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic bfloat, ptr addrspace(1) [[PTR]] seq_cst, align 2, !some.unknown.md [[META0]]
90 ; CHECK-NEXT: ret bfloat [[TMP2]]
92 %ld = load atomic bfloat, ptr addrspace(1) %ptr seq_cst, align 2, !some.unknown.md !0
96 define bfloat @load_atomic_bf16_global_agent(ptr addrspace(1) %ptr) {
97 ; CHECK-LABEL: define bfloat @load_atomic_bf16_global_agent(
98 ; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]]) {
99 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic bfloat, ptr addrspace(1) [[PTR]] syncscope("agent") seq_cst, align 2, !some.unknown.md [[META0]]
100 ; CHECK-NEXT: ret bfloat [[TMP2]]
102 %ld = load atomic bfloat, ptr addrspace(1) %ptr syncscope("agent") seq_cst, align 2, !some.unknown.md !0
106 define bfloat @load_atomic_bf16_local(ptr addrspace(3) %ptr) {
107 ; CHECK-LABEL: define bfloat @load_atomic_bf16_local(
108 ; CHECK-SAME: ptr addrspace(3) [[PTR:%.*]]) {
109 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic bfloat, ptr addrspace(3) [[PTR]] seq_cst, align 2, !some.unknown.md [[META0]]
110 ; CHECK-NEXT: ret bfloat [[TMP2]]
112 %ld = load atomic bfloat, ptr addrspace(3) %ptr seq_cst, align 2, !some.unknown.md !0
116 define bfloat @load_atomic_bf16_flat(ptr %ptr) {
117 ; CHECK-LABEL: define bfloat @load_atomic_bf16_flat(
118 ; CHECK-SAME: ptr [[PTR:%.*]]) {
119 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic bfloat, ptr [[PTR]] seq_cst, align 2, !some.unknown.md [[META0]]
120 ; CHECK-NEXT: ret bfloat [[TMP2]]
122 %ld = load atomic bfloat, ptr %ptr seq_cst, align 2, !some.unknown.md !0
126 define double @load_atomic_f64_global_system(ptr addrspace(1) %ptr) {
127 ; CHECK-LABEL: define double @load_atomic_f64_global_system(
128 ; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]]) {
129 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic double, ptr addrspace(1) [[PTR]] seq_cst, align 8, !some.unknown.md [[META0]]
130 ; CHECK-NEXT: ret double [[TMP2]]
132 %ld = load atomic double, ptr addrspace(1) %ptr seq_cst, align 8, !some.unknown.md !0
136 define double @load_atomic_f64_global_agent(ptr addrspace(1) %ptr) {
137 ; CHECK-LABEL: define double @load_atomic_f64_global_agent(
138 ; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]]) {
139 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic double, ptr addrspace(1) [[PTR]] syncscope("agent") seq_cst, align 8, !some.unknown.md [[META0]]
140 ; CHECK-NEXT: ret double [[TMP2]]
142 %ld = load atomic double, ptr addrspace(1) %ptr syncscope("agent") seq_cst, align 8, !some.unknown.md !0
146 define double @load_atomic_f64_local(ptr addrspace(3) %ptr) {
147 ; CHECK-LABEL: define double @load_atomic_f64_local(
148 ; CHECK-SAME: ptr addrspace(3) [[PTR:%.*]]) {
149 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic double, ptr addrspace(3) [[PTR]] seq_cst, align 8, !some.unknown.md [[META0]]
150 ; CHECK-NEXT: ret double [[TMP2]]
152 %ld = load atomic double, ptr addrspace(3) %ptr seq_cst, align 8, !some.unknown.md !0
156 define double @load_atomic_f64_flat_system(ptr %ptr) {
157 ; CHECK-LABEL: define double @load_atomic_f64_flat_system(
158 ; CHECK-SAME: ptr [[PTR:%.*]]) {
159 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic double, ptr [[PTR]] seq_cst, align 8, !some.unknown.md [[META0]]
160 ; CHECK-NEXT: ret double [[TMP2]]
162 %ld = load atomic double, ptr %ptr seq_cst, align 8, !some.unknown.md !0
166 define double @load_atomic_f64_flat_agent(ptr %ptr) {
167 ; CHECK-LABEL: define double @load_atomic_f64_flat_agent(
168 ; CHECK-SAME: ptr [[PTR:%.*]]) {
169 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic double, ptr [[PTR]] syncscope("agent") seq_cst, align 8, !some.unknown.md [[META0]]
170 ; CHECK-NEXT: ret double [[TMP2]]
172 %ld = load atomic double, ptr %ptr syncscope("agent") seq_cst, align 8, !some.unknown.md !0
180 ; CHECK: [[META0]] = !{}