1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=hawaii -atomic-expand %s | FileCheck -check-prefix=GCN %s
3 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -atomic-expand %s | FileCheck -check-prefix=GCN %s
5 define float @test_atomicrmw_fadd_f32_flat(float* %ptr, float %value) {
6 ; GCN-LABEL: @test_atomicrmw_fadd_f32_flat(
7 ; GCN-NEXT: [[TMP1:%.*]] = load float, float* [[PTR:%.*]], align 4
8 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
9 ; GCN: atomicrmw.start:
10 ; GCN-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
11 ; GCN-NEXT: [[NEW:%.*]] = fsub float [[LOADED]], [[VALUE:%.*]]
12 ; GCN-NEXT: [[TMP2:%.*]] = bitcast float* [[PTR]] to i32*
13 ; GCN-NEXT: [[TMP3:%.*]] = bitcast float [[NEW]] to i32
14 ; GCN-NEXT: [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
15 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i32* [[TMP2]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
16 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
17 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
18 ; GCN-NEXT: [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
19 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
21 ; GCN-NEXT: ret float [[TMP6]]
23 %res = atomicrmw fsub float* %ptr, float %value seq_cst
27 define float @test_atomicrmw_fsub_f32_global(float addrspace(1)* %ptr, float %value) {
28 ; GCN-LABEL: @test_atomicrmw_fsub_f32_global(
29 ; GCN-NEXT: [[TMP1:%.*]] = load float, float addrspace(1)* [[PTR:%.*]], align 4
30 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
31 ; GCN: atomicrmw.start:
32 ; GCN-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
33 ; GCN-NEXT: [[NEW:%.*]] = fsub float [[LOADED]], [[VALUE:%.*]]
34 ; GCN-NEXT: [[TMP2:%.*]] = bitcast float addrspace(1)* [[PTR]] to i32 addrspace(1)*
35 ; GCN-NEXT: [[TMP3:%.*]] = bitcast float [[NEW]] to i32
36 ; GCN-NEXT: [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
37 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i32 addrspace(1)* [[TMP2]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
38 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
39 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
40 ; GCN-NEXT: [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
41 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
43 ; GCN-NEXT: ret float [[TMP6]]
45 %res = atomicrmw fsub float addrspace(1)* %ptr, float %value seq_cst
49 define float @test_atomicrmw_fsub_f32_local(float addrspace(3)* %ptr, float %value) {
50 ; GCN-LABEL: @test_atomicrmw_fsub_f32_local(
51 ; GCN-NEXT: [[TMP1:%.*]] = load float, float addrspace(3)* [[PTR:%.*]], align 4
52 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
53 ; GCN: atomicrmw.start:
54 ; GCN-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
55 ; GCN-NEXT: [[NEW:%.*]] = fsub float [[LOADED]], [[VALUE:%.*]]
56 ; GCN-NEXT: [[TMP2:%.*]] = bitcast float addrspace(3)* [[PTR]] to i32 addrspace(3)*
57 ; GCN-NEXT: [[TMP3:%.*]] = bitcast float [[NEW]] to i32
58 ; GCN-NEXT: [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
59 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i32 addrspace(3)* [[TMP2]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
60 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
61 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
62 ; GCN-NEXT: [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
63 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
65 ; GCN-NEXT: ret float [[TMP6]]
67 %res = atomicrmw fsub float addrspace(3)* %ptr, float %value seq_cst
71 define half @test_atomicrmw_fsub_f16_flat(half* %ptr, half %value) {
72 ; GCN-LABEL: @test_atomicrmw_fsub_f16_flat(
73 ; GCN-NEXT: [[RES:%.*]] = atomicrmw fsub half* [[PTR:%.*]], half [[VALUE:%.*]] seq_cst
74 ; GCN-NEXT: ret half [[RES]]
76 %res = atomicrmw fsub half* %ptr, half %value seq_cst
80 define half @test_atomicrmw_fsub_f16_global(half addrspace(1)* %ptr, half %value) {
81 ; GCN-LABEL: @test_atomicrmw_fsub_f16_global(
82 ; GCN-NEXT: [[RES:%.*]] = atomicrmw fsub half addrspace(1)* [[PTR:%.*]], half [[VALUE:%.*]] seq_cst
83 ; GCN-NEXT: ret half [[RES]]
85 %res = atomicrmw fsub half addrspace(1)* %ptr, half %value seq_cst
89 define half @test_atomicrmw_fsub_f16_local(half addrspace(3)* %ptr, half %value) {
90 ; GCN-LABEL: @test_atomicrmw_fsub_f16_local(
91 ; GCN-NEXT: [[RES:%.*]] = atomicrmw fsub half addrspace(3)* [[PTR:%.*]], half [[VALUE:%.*]] seq_cst
92 ; GCN-NEXT: ret half [[RES]]
94 %res = atomicrmw fsub half addrspace(3)* %ptr, half %value seq_cst
98 define double @test_atomicrmw_fsub_f64_flat(double* %ptr, double %value) {
99 ; GCN-LABEL: @test_atomicrmw_fsub_f64_flat(
100 ; GCN-NEXT: [[TMP1:%.*]] = load double, double* [[PTR:%.*]], align 8
101 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
102 ; GCN: atomicrmw.start:
103 ; GCN-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
104 ; GCN-NEXT: [[NEW:%.*]] = fsub double [[LOADED]], [[VALUE:%.*]]
105 ; GCN-NEXT: [[TMP2:%.*]] = bitcast double* [[PTR]] to i64*
106 ; GCN-NEXT: [[TMP3:%.*]] = bitcast double [[NEW]] to i64
107 ; GCN-NEXT: [[TMP4:%.*]] = bitcast double [[LOADED]] to i64
108 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i64* [[TMP2]], i64 [[TMP4]], i64 [[TMP3]] seq_cst seq_cst
109 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP5]], 1
110 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP5]], 0
111 ; GCN-NEXT: [[TMP6]] = bitcast i64 [[NEWLOADED]] to double
112 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
113 ; GCN: atomicrmw.end:
114 ; GCN-NEXT: ret double [[TMP6]]
116 %res = atomicrmw fsub double* %ptr, double %value seq_cst
120 define double @test_atomicrmw_fsub_f64_global(double addrspace(1)* %ptr, double %value) {
121 ; GCN-LABEL: @test_atomicrmw_fsub_f64_global(
122 ; GCN-NEXT: [[TMP1:%.*]] = load double, double addrspace(1)* [[PTR:%.*]], align 8
123 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
124 ; GCN: atomicrmw.start:
125 ; GCN-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
126 ; GCN-NEXT: [[NEW:%.*]] = fsub double [[LOADED]], [[VALUE:%.*]]
127 ; GCN-NEXT: [[TMP2:%.*]] = bitcast double addrspace(1)* [[PTR]] to i64 addrspace(1)*
128 ; GCN-NEXT: [[TMP3:%.*]] = bitcast double [[NEW]] to i64
129 ; GCN-NEXT: [[TMP4:%.*]] = bitcast double [[LOADED]] to i64
130 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i64 addrspace(1)* [[TMP2]], i64 [[TMP4]], i64 [[TMP3]] seq_cst seq_cst
131 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP5]], 1
132 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP5]], 0
133 ; GCN-NEXT: [[TMP6]] = bitcast i64 [[NEWLOADED]] to double
134 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
135 ; GCN: atomicrmw.end:
136 ; GCN-NEXT: ret double [[TMP6]]
138 %res = atomicrmw fsub double addrspace(1)* %ptr, double %value seq_cst
142 define double @test_atomicrmw_fsub_f64_local(double addrspace(3)* %ptr, double %value) {
143 ; GCN-LABEL: @test_atomicrmw_fsub_f64_local(
144 ; GCN-NEXT: [[TMP1:%.*]] = load double, double addrspace(3)* [[PTR:%.*]], align 8
145 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
146 ; GCN: atomicrmw.start:
147 ; GCN-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
148 ; GCN-NEXT: [[NEW:%.*]] = fsub double [[LOADED]], [[VALUE:%.*]]
149 ; GCN-NEXT: [[TMP2:%.*]] = bitcast double addrspace(3)* [[PTR]] to i64 addrspace(3)*
150 ; GCN-NEXT: [[TMP3:%.*]] = bitcast double [[NEW]] to i64
151 ; GCN-NEXT: [[TMP4:%.*]] = bitcast double [[LOADED]] to i64
152 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i64 addrspace(3)* [[TMP2]], i64 [[TMP4]], i64 [[TMP3]] seq_cst seq_cst
153 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP5]], 1
154 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP5]], 0
155 ; GCN-NEXT: [[TMP6]] = bitcast i64 [[NEWLOADED]] to double
156 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
157 ; GCN: atomicrmw.end:
158 ; GCN-NEXT: ret double [[TMP6]]
160 %res = atomicrmw fsub double addrspace(3)* %ptr, double %value seq_cst