xref: /llvm-project/llvm/test/CodeGen/DirectX/fmad.ll (revision 011b618644113996e2c0a8e57db40f89d20878e3)
1; RUN: opt -S -dxil-op-lower < %s | FileCheck %s
2
3; Make sure dxil operation function calls for round are generated for float and half.
4; CHECK:call half @dx.op.tertiary.f16(i32 46, half %{{.*}}, half %{{.*}}, half %{{.*}}) #[[#ATTR:]]
5; CHECK:call float @dx.op.tertiary.f32(i32 46, float %{{.*}}, float %{{.*}}, float %{{.*}}) #[[#ATTR]]
6; CHECK:call double @dx.op.tertiary.f64(i32 46, double %{{.*}}, double %{{.*}}, double %{{.*}}) #[[#ATTR]]
7
8; CHECK: attributes #[[#ATTR]] = {{{.*}} memory(none) {{.*}}}
9
10target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
11target triple = "dxil-pc-shadermodel6.7-library"
12
13; Function Attrs: noinline nounwind optnone
14define noundef half @fmad_half(half noundef %p0, half noundef %p1, half noundef %p2) #0 {
15entry:
16  %p2.addr = alloca half, align 2
17  %p1.addr = alloca half, align 2
18  %p0.addr = alloca half, align 2
19  store half %p2, ptr %p2.addr, align 2
20  store half %p1, ptr %p1.addr, align 2
21  store half %p0, ptr %p0.addr, align 2
22  %0 = load half, ptr %p0.addr, align 2
23  %1 = load half, ptr %p1.addr, align 2
24  %2 = load half, ptr %p2.addr, align 2
25  %hlsl.fmad = call half @llvm.fmuladd.f16(half %0, half %1, half %2)
26  ret half %hlsl.fmad
27}
28
29; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
30declare half @llvm.fmuladd.f16(half, half, half) #2
31
32; Function Attrs: noinline nounwind optnone
33define noundef float @fmad_float(float noundef %p0, float noundef %p1, float noundef %p2) #0 {
34entry:
35  %p2.addr = alloca float, align 4
36  %p1.addr = alloca float, align 4
37  %p0.addr = alloca float, align 4
38  store float %p2, ptr %p2.addr, align 4
39  store float %p1, ptr %p1.addr, align 4
40  store float %p0, ptr %p0.addr, align 4
41  %0 = load float, ptr %p0.addr, align 4
42  %1 = load float, ptr %p1.addr, align 4
43  %2 = load float, ptr %p2.addr, align 4
44  %hlsl.fmad = call float @llvm.fmuladd.f32(float %0, float %1, float %2)
45  ret float %hlsl.fmad
46}
47
48; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
49declare float @llvm.fmuladd.f32(float, float, float) #2
50
51; Function Attrs: noinline nounwind optnone
52define noundef double @fmad_double(double noundef %p0, double noundef %p1, double noundef %p2) #0 {
53entry:
54  %p2.addr = alloca double, align 8
55  %p1.addr = alloca double, align 8
56  %p0.addr = alloca double, align 8
57  store double %p2, ptr %p2.addr, align 8
58  store double %p1, ptr %p1.addr, align 8
59  store double %p0, ptr %p0.addr, align 8
60  %0 = load double, ptr %p0.addr, align 8
61  %1 = load double, ptr %p1.addr, align 8
62  %2 = load double, ptr %p2.addr, align 8
63  %hlsl.fmad = call double @llvm.fmuladd.f64(double %0, double %1, double %2)
64  ret double %hlsl.fmad
65}
66
67; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
68declare double @llvm.fmuladd.f64(double, double, double) #2
69