1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=amdgpu-simplifylib %s | FileCheck %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-G1-ni:7:8:9"
6 declare float @_Z3madfff(float, float, float)
7 declare <2 x float> @_Z3madDv2_fS_S_(<2 x float>, <2 x float>, <2 x float>)
8 declare <3 x float> @_Z3madDv3_fS_S_(<3 x float>, <3 x float>, <3 x float>)
9 declare <4 x float> @_Z3madDv4_fS_S_(<4 x float>, <4 x float>, <4 x float>)
10 declare <8 x float> @_Z3madDv8_fS_S_(<8 x float>, <8 x float>, <8 x float>)
11 declare <16 x float> @_Z3madDv16_fS_S_(<16 x float>, <16 x float>, <16 x float>)
12 declare double @_Z3madddd(double, double, double)
13 declare <2 x double> @_Z3madDv2_dS_S_(<2 x double>, <2 x double>, <2 x double>)
14 declare <3 x double> @_Z3madDv3_dS_S_(<3 x double>, <3 x double>, <3 x double>)
15 declare <4 x double> @_Z3madDv4_dS_S_(<4 x double>, <4 x double>, <4 x double>)
16 declare <8 x double> @_Z3madDv8_dS_S_(<8 x double>, <8 x double>, <8 x double>)
17 declare <16 x double> @_Z3madDv16_dS_S_(<16 x double>, <16 x double>, <16 x double>)
18 declare half @_Z3madDhDhDh(half, half, half)
19 declare <2 x half> @_Z3madDv2_DhS_S_(<2 x half>, <2 x half>, <2 x half>)
20 declare <3 x half> @_Z3madDv3_DhS_S_(<3 x half>, <3 x half>, <3 x half>)
21 declare <4 x half> @_Z3madDv4_DhS_S_(<4 x half>, <4 x half>, <4 x half>)
22 declare <8 x half> @_Z3madDv8_DhS_S_(<8 x half>, <8 x half>, <8 x half>)
23 declare <16 x half> @_Z3madDv16_DhS_S_(<16 x half>, <16 x half>, <16 x half>)
25 define float @test_mad_f32(float %x, float %y, float %z) {
26 ; CHECK-LABEL: define float @test_mad_f32
27 ; CHECK-SAME: (float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]]) {
28 ; CHECK-NEXT: [[MAD:%.*]] = tail call float @llvm.fmuladd.f32(float [[X]], float [[Y]], float [[Z]])
29 ; CHECK-NEXT: ret float [[MAD]]
31 %mad = tail call float @_Z3madfff(float %x, float %y, float %z)
35 define <2 x float> @test_mad_v2f32(<2 x float> %x, <2 x float> %y, <2 x float> %z) {
36 ; CHECK-LABEL: define <2 x float> @test_mad_v2f32
37 ; CHECK-SAME: (<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]], <2 x float> [[Z:%.*]]) {
38 ; CHECK-NEXT: [[MAD:%.*]] = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> [[X]], <2 x float> [[Y]], <2 x float> [[Z]])
39 ; CHECK-NEXT: ret <2 x float> [[MAD]]
41 %mad = tail call <2 x float> @_Z3madDv2_fS_S_(<2 x float> %x, <2 x float> %y, <2 x float> %z)
45 define <3 x float> @test_mad_v3f32(<3 x float> %x, <3 x float> %y, <3 x float> %z) {
46 ; CHECK-LABEL: define <3 x float> @test_mad_v3f32
47 ; CHECK-SAME: (<3 x float> [[X:%.*]], <3 x float> [[Y:%.*]], <3 x float> [[Z:%.*]]) {
48 ; CHECK-NEXT: [[MAD:%.*]] = tail call <3 x float> @llvm.fmuladd.v3f32(<3 x float> [[X]], <3 x float> [[Y]], <3 x float> [[Z]])
49 ; CHECK-NEXT: ret <3 x float> [[MAD]]
51 %mad = tail call <3 x float> @_Z3madDv3_fS_S_(<3 x float> %x, <3 x float> %y, <3 x float> %z)
55 define <4 x float> @test_mad_v4f32(<4 x float> %x, <4 x float> %y, <4 x float> %z) {
56 ; CHECK-LABEL: define <4 x float> @test_mad_v4f32
57 ; CHECK-SAME: (<4 x float> [[X:%.*]], <4 x float> [[Y:%.*]], <4 x float> [[Z:%.*]]) {
58 ; CHECK-NEXT: [[MAD:%.*]] = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> [[X]], <4 x float> [[Y]], <4 x float> [[Z]])
59 ; CHECK-NEXT: ret <4 x float> [[MAD]]
61 %mad = tail call <4 x float> @_Z3madDv4_fS_S_(<4 x float> %x, <4 x float> %y, <4 x float> %z)
65 define <8 x float> @test_mad_v8f32(<8 x float> %x, <8 x float> %y, <8 x float> %z) {
66 ; CHECK-LABEL: define <8 x float> @test_mad_v8f32
67 ; CHECK-SAME: (<8 x float> [[X:%.*]], <8 x float> [[Y:%.*]], <8 x float> [[Z:%.*]]) {
68 ; CHECK-NEXT: [[MAD:%.*]] = tail call <8 x float> @llvm.fmuladd.v8f32(<8 x float> [[X]], <8 x float> [[Y]], <8 x float> [[Z]])
69 ; CHECK-NEXT: ret <8 x float> [[MAD]]
71 %mad = tail call <8 x float> @_Z3madDv8_fS_S_(<8 x float> %x, <8 x float> %y, <8 x float> %z)
75 define <16 x float> @test_mad_v16f32(<16 x float> %x, <16 x float> %y, <16 x float> %z) {
76 ; CHECK-LABEL: define <16 x float> @test_mad_v16f32
77 ; CHECK-SAME: (<16 x float> [[X:%.*]], <16 x float> [[Y:%.*]], <16 x float> [[Z:%.*]]) {
78 ; CHECK-NEXT: [[MAD:%.*]] = tail call <16 x float> @llvm.fmuladd.v16f32(<16 x float> [[X]], <16 x float> [[Y]], <16 x float> [[Z]])
79 ; CHECK-NEXT: ret <16 x float> [[MAD]]
81 %mad = tail call <16 x float> @_Z3madDv16_fS_S_(<16 x float> %x, <16 x float> %y, <16 x float> %z)
85 define double @test_mad_f64(double %x, double %y, double %z) {
86 ; CHECK-LABEL: define double @test_mad_f64
87 ; CHECK-SAME: (double [[X:%.*]], double [[Y:%.*]], double [[Z:%.*]]) {
88 ; CHECK-NEXT: [[MAD:%.*]] = tail call double @llvm.fmuladd.f64(double [[X]], double [[Y]], double [[Z]])
89 ; CHECK-NEXT: ret double [[MAD]]
91 %mad = tail call double @_Z3madddd(double %x, double %y, double %z)
95 define <2 x double> @test_mad_v2f64(<2 x double> %x, <2 x double> %y, <2 x double> %z) {
96 ; CHECK-LABEL: define <2 x double> @test_mad_v2f64
97 ; CHECK-SAME: (<2 x double> [[X:%.*]], <2 x double> [[Y:%.*]], <2 x double> [[Z:%.*]]) {
98 ; CHECK-NEXT: [[MAD:%.*]] = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> [[X]], <2 x double> [[Y]], <2 x double> [[Z]])
99 ; CHECK-NEXT: ret <2 x double> [[MAD]]
101 %mad = tail call <2 x double> @_Z3madDv2_dS_S_(<2 x double> %x, <2 x double> %y, <2 x double> %z)
102 ret <2 x double> %mad
105 define <3 x double> @test_mad_v3f64(<3 x double> %x, <3 x double> %y, <3 x double> %z) {
106 ; CHECK-LABEL: define <3 x double> @test_mad_v3f64
107 ; CHECK-SAME: (<3 x double> [[X:%.*]], <3 x double> [[Y:%.*]], <3 x double> [[Z:%.*]]) {
108 ; CHECK-NEXT: [[MAD:%.*]] = tail call <3 x double> @llvm.fmuladd.v3f64(<3 x double> [[X]], <3 x double> [[Y]], <3 x double> [[Z]])
109 ; CHECK-NEXT: ret <3 x double> [[MAD]]
111 %mad = tail call <3 x double> @_Z3madDv3_dS_S_(<3 x double> %x, <3 x double> %y, <3 x double> %z)
112 ret <3 x double> %mad
115 define <4 x double> @test_mad_v4f64(<4 x double> %x, <4 x double> %y, <4 x double> %z) {
116 ; CHECK-LABEL: define <4 x double> @test_mad_v4f64
117 ; CHECK-SAME: (<4 x double> [[X:%.*]], <4 x double> [[Y:%.*]], <4 x double> [[Z:%.*]]) {
118 ; CHECK-NEXT: [[MAD:%.*]] = tail call <4 x double> @llvm.fmuladd.v4f64(<4 x double> [[X]], <4 x double> [[Y]], <4 x double> [[Z]])
119 ; CHECK-NEXT: ret <4 x double> [[MAD]]
121 %mad = tail call <4 x double> @_Z3madDv4_dS_S_(<4 x double> %x, <4 x double> %y, <4 x double> %z)
122 ret <4 x double> %mad
125 define <8 x double> @test_mad_v8f64(<8 x double> %x, <8 x double> %y, <8 x double> %z) {
126 ; CHECK-LABEL: define <8 x double> @test_mad_v8f64
127 ; CHECK-SAME: (<8 x double> [[X:%.*]], <8 x double> [[Y:%.*]], <8 x double> [[Z:%.*]]) {
128 ; CHECK-NEXT: [[MAD:%.*]] = tail call <8 x double> @llvm.fmuladd.v8f64(<8 x double> [[X]], <8 x double> [[Y]], <8 x double> [[Z]])
129 ; CHECK-NEXT: ret <8 x double> [[MAD]]
131 %mad = tail call <8 x double> @_Z3madDv8_dS_S_(<8 x double> %x, <8 x double> %y, <8 x double> %z)
132 ret <8 x double> %mad
135 define <16 x double> @test_mad_v16f64(<16 x double> %x, <16 x double> %y, <16 x double> %z) {
136 ; CHECK-LABEL: define <16 x double> @test_mad_v16f64
137 ; CHECK-SAME: (<16 x double> [[X:%.*]], <16 x double> [[Y:%.*]], <16 x double> [[Z:%.*]]) {
138 ; CHECK-NEXT: [[MAD:%.*]] = tail call <16 x double> @llvm.fmuladd.v16f64(<16 x double> [[X]], <16 x double> [[Y]], <16 x double> [[Z]])
139 ; CHECK-NEXT: ret <16 x double> [[MAD]]
141 %mad = tail call <16 x double> @_Z3madDv16_dS_S_(<16 x double> %x, <16 x double> %y, <16 x double> %z)
142 ret <16 x double> %mad
145 define half @test_mad_f16(half %x, half %y, half %z) {
146 ; CHECK-LABEL: define half @test_mad_f16
147 ; CHECK-SAME: (half [[X:%.*]], half [[Y:%.*]], half [[Z:%.*]]) {
148 ; CHECK-NEXT: [[MAD:%.*]] = tail call half @llvm.fmuladd.f16(half [[X]], half [[Y]], half [[Z]])
149 ; CHECK-NEXT: ret half [[MAD]]
151 %mad = tail call half @_Z3madDhDhDh(half %x, half %y, half %z)
155 define <2 x half> @test_mad_v2f16(<2 x half> %x, <2 x half> %y, <2 x half> %z) {
156 ; CHECK-LABEL: define <2 x half> @test_mad_v2f16
157 ; CHECK-SAME: (<2 x half> [[X:%.*]], <2 x half> [[Y:%.*]], <2 x half> [[Z:%.*]]) {
158 ; CHECK-NEXT: [[MAD:%.*]] = tail call <2 x half> @llvm.fmuladd.v2f16(<2 x half> [[X]], <2 x half> [[Y]], <2 x half> [[Z]])
159 ; CHECK-NEXT: ret <2 x half> [[MAD]]
161 %mad = tail call <2 x half> @_Z3madDv2_DhS_S_(<2 x half> %x, <2 x half> %y, <2 x half> %z)
165 define <3 x half> @test_mad_v3f16(<3 x half> %x, <3 x half> %y, <3 x half> %z) {
166 ; CHECK-LABEL: define <3 x half> @test_mad_v3f16
167 ; CHECK-SAME: (<3 x half> [[X:%.*]], <3 x half> [[Y:%.*]], <3 x half> [[Z:%.*]]) {
168 ; CHECK-NEXT: [[MAD:%.*]] = tail call <3 x half> @llvm.fmuladd.v3f16(<3 x half> [[X]], <3 x half> [[Y]], <3 x half> [[Z]])
169 ; CHECK-NEXT: ret <3 x half> [[MAD]]
171 %mad = tail call <3 x half> @_Z3madDv3_DhS_S_(<3 x half> %x, <3 x half> %y, <3 x half> %z)
175 define <4 x half> @test_mad_v4f16(<4 x half> %x, <4 x half> %y, <4 x half> %z) {
176 ; CHECK-LABEL: define <4 x half> @test_mad_v4f16
177 ; CHECK-SAME: (<4 x half> [[X:%.*]], <4 x half> [[Y:%.*]], <4 x half> [[Z:%.*]]) {
178 ; CHECK-NEXT: [[MAD:%.*]] = tail call <4 x half> @llvm.fmuladd.v4f16(<4 x half> [[X]], <4 x half> [[Y]], <4 x half> [[Z]])
179 ; CHECK-NEXT: ret <4 x half> [[MAD]]
181 %mad = tail call <4 x half> @_Z3madDv4_DhS_S_(<4 x half> %x, <4 x half> %y, <4 x half> %z)
185 define <8 x half> @test_mad_v8f16(<8 x half> %x, <8 x half> %y, <8 x half> %z) {
186 ; CHECK-LABEL: define <8 x half> @test_mad_v8f16
187 ; CHECK-SAME: (<8 x half> [[X:%.*]], <8 x half> [[Y:%.*]], <8 x half> [[Z:%.*]]) {
188 ; CHECK-NEXT: [[MAD:%.*]] = tail call <8 x half> @llvm.fmuladd.v8f16(<8 x half> [[X]], <8 x half> [[Y]], <8 x half> [[Z]])
189 ; CHECK-NEXT: ret <8 x half> [[MAD]]
191 %mad = tail call <8 x half> @_Z3madDv8_DhS_S_(<8 x half> %x, <8 x half> %y, <8 x half> %z)
195 define <16 x half> @test_mad_v16f16(<16 x half> %x, <16 x half> %y, <16 x half> %z) {
196 ; CHECK-LABEL: define <16 x half> @test_mad_v16f16
197 ; CHECK-SAME: (<16 x half> [[X:%.*]], <16 x half> [[Y:%.*]], <16 x half> [[Z:%.*]]) {
198 ; CHECK-NEXT: [[MAD:%.*]] = tail call <16 x half> @llvm.fmuladd.v16f16(<16 x half> [[X]], <16 x half> [[Y]], <16 x half> [[Z]])
199 ; CHECK-NEXT: ret <16 x half> [[MAD]]
201 %mad = tail call <16 x half> @_Z3madDv16_DhS_S_(<16 x half> %x, <16 x half> %y, <16 x half> %z)
205 define float @test_mad_f32_fast(float %x, float %y, float %z) {
206 ; CHECK-LABEL: define float @test_mad_f32_fast
207 ; CHECK-SAME: (float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]]) {
208 ; CHECK-NEXT: [[MAD:%.*]] = tail call fast float @llvm.fmuladd.f32(float [[X]], float [[Y]], float [[Z]])
209 ; CHECK-NEXT: ret float [[MAD]]
211 %mad = tail call fast float @_Z3madfff(float %x, float %y, float %z)
215 define float @test_mad_f32_noinline(float %x, float %y, float %z) {
216 ; CHECK-LABEL: define float @test_mad_f32_noinline
217 ; CHECK-SAME: (float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]]) {
218 ; CHECK-NEXT: [[MAD:%.*]] = tail call fast float @_Z3madfff(float [[X]], float [[Y]], float [[Z]]) #[[ATTR3:[0-9]+]]
219 ; CHECK-NEXT: ret float [[MAD]]
221 %mad = tail call fast float @_Z3madfff(float %x, float %y, float %z) #1
225 define float @test_mad_f32_fast_minsize(float %x, float %y, float %z) #0 {
226 ; CHECK-LABEL: define float @test_mad_f32_fast_minsize
227 ; CHECK-SAME: (float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]]) #[[ATTR0:[0-9]+]] {
228 ; CHECK-NEXT: [[MAD:%.*]] = tail call fast float @llvm.fmuladd.f32(float [[X]], float [[Y]], float [[Z]])
229 ; CHECK-NEXT: ret float [[MAD]]
231 %mad = tail call fast float @_Z3madfff(float %x, float %y, float %z)
235 define float @test_mad_f32_fast_strictfp(float %x, float %y, float %z) #2 {
236 ; CHECK-LABEL: define float @test_mad_f32_fast_strictfp
237 ; CHECK-SAME: (float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]]) #[[ATTR1:[0-9]+]] {
238 ; CHECK-NEXT: [[MAD:%.*]] = tail call nnan nsz float @_Z3madfff(float [[X]], float [[Y]], float [[Z]]) #[[ATTR1]]
239 ; CHECK-NEXT: ret float [[MAD]]
241 %mad = tail call nsz nnan float @_Z3madfff(float %x, float %y, float %z) #2
245 define float @test_mad_f32_fast_nobuiltin(float %x, float %y, float %z) {
246 ; CHECK-LABEL: define float @test_mad_f32_fast_nobuiltin
247 ; CHECK-SAME: (float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]]) {
248 ; CHECK-NEXT: [[MAD:%.*]] = tail call fast float @_Z3madfff(float [[X]], float [[Y]], float [[Z]]) #[[ATTR4:[0-9]+]]
249 ; CHECK-NEXT: ret float [[MAD]]
251 %mad = tail call fast float @_Z3madfff(float %x, float %y, float %z) #3
255 attributes #0 = { minsize }
256 attributes #1 = { noinline }
257 attributes #2 = { strictfp }
258 attributes #3 = { nobuiltin }