xref: /llvm-project/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.fma.legacy.ll (revision f2c164c8150548d983565c4ddc0fde790f9e2a5b)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx1030 < %s | FileCheck -check-prefix=GFX10 %s
3; RUN: llc -global-isel -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx1030 < %s | FileCheck -check-prefix=GFX10 %s
4; RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx1100 < %s | FileCheck -check-prefix=GFX11 %s
5; RUN: llc -global-isel -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx1100 < %s | FileCheck -check-prefix=GFX11 %s
6
7define float @v_fma(float %a, float %b, float %c)  {
8; GFX10-LABEL: v_fma:
9; GFX10:       ; %bb.0:
10; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
11; GFX10-NEXT:    v_fma_legacy_f32 v0, v0, v1, v2
12; GFX10-NEXT:    s_setpc_b64 s[30:31]
13;
14; GFX11-LABEL: v_fma:
15; GFX11:       ; %bb.0:
16; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
17; GFX11-NEXT:    v_fma_dx9_zero_f32 v0, v0, v1, v2
18; GFX11-NEXT:    s_setpc_b64 s[30:31]
19  %fma = call float @llvm.amdgcn.fma.legacy(float %a, float %b, float %c)
20  ret float %fma
21}
22
23define float @v_fma_imm(float %a, float %c)  {
24; GFX10-LABEL: v_fma_imm:
25; GFX10:       ; %bb.0:
26; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
27; GFX10-NEXT:    v_fma_legacy_f32 v0, 0x41200000, v0, v1
28; GFX10-NEXT:    s_setpc_b64 s[30:31]
29;
30; GFX11-LABEL: v_fma_imm:
31; GFX11:       ; %bb.0:
32; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
33; GFX11-NEXT:    v_fma_dx9_zero_f32 v0, 0x41200000, v0, v1
34; GFX11-NEXT:    s_setpc_b64 s[30:31]
35  %fma = call float @llvm.amdgcn.fma.legacy(float %a, float 10.0, float %c)
36  ret float %fma
37}
38
39define float @v_fabs_fma(float %a, float %b, float %c)  {
40; GFX10-LABEL: v_fabs_fma:
41; GFX10:       ; %bb.0:
42; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
43; GFX10-NEXT:    v_fma_legacy_f32 v0, |v0|, v1, v2
44; GFX10-NEXT:    s_setpc_b64 s[30:31]
45;
46; GFX11-LABEL: v_fabs_fma:
47; GFX11:       ; %bb.0:
48; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
49; GFX11-NEXT:    v_fma_dx9_zero_f32 v0, |v0|, v1, v2
50; GFX11-NEXT:    s_setpc_b64 s[30:31]
51  %fabs.a = call float @llvm.fabs.f32(float %a)
52  %fma = call float @llvm.amdgcn.fma.legacy(float %fabs.a, float %b, float %c)
53  ret float %fma
54}
55
56define float @v_fneg_fabs_fma(float %a, float %b, float %c)  {
57; GFX10-LABEL: v_fneg_fabs_fma:
58; GFX10:       ; %bb.0:
59; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
60; GFX10-NEXT:    v_fma_legacy_f32 v0, v0, -|v1|, v2
61; GFX10-NEXT:    s_setpc_b64 s[30:31]
62;
63; GFX11-LABEL: v_fneg_fabs_fma:
64; GFX11:       ; %bb.0:
65; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
66; GFX11-NEXT:    v_fma_dx9_zero_f32 v0, v0, -|v1|, v2
67; GFX11-NEXT:    s_setpc_b64 s[30:31]
68  %fabs.b = call float @llvm.fabs.f32(float %b)
69  %neg.fabs.b = fneg float %fabs.b
70  %fma = call float @llvm.amdgcn.fma.legacy(float %a, float %neg.fabs.b, float %c)
71  ret float %fma
72}
73
74define float @v_fneg_fma(float %a, float %b, float %c)  {
75; GFX10-LABEL: v_fneg_fma:
76; GFX10:       ; %bb.0:
77; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
78; GFX10-NEXT:    v_fma_legacy_f32 v0, v0, v1, -v2
79; GFX10-NEXT:    s_setpc_b64 s[30:31]
80;
81; GFX11-LABEL: v_fneg_fma:
82; GFX11:       ; %bb.0:
83; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
84; GFX11-NEXT:    v_fma_dx9_zero_f32 v0, v0, v1, -v2
85; GFX11-NEXT:    s_setpc_b64 s[30:31]
86  %neg.c = fneg float %c
87  %fma = call float @llvm.amdgcn.fma.legacy(float %a, float %b, float %neg.c)
88  ret float %fma
89}
90
91define float @v_fma_const_const(float %a)  {
92; GFX10-LABEL: v_fma_const_const:
93; GFX10:       ; %bb.0:
94; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
95; GFX10-NEXT:    v_fma_legacy_f32 v0, v0, 2.0, -1.0
96; GFX10-NEXT:    s_setpc_b64 s[30:31]
97;
98; GFX11-LABEL: v_fma_const_const:
99; GFX11:       ; %bb.0:
100; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
101; GFX11-NEXT:    v_fma_dx9_zero_f32 v0, v0, 2.0, -1.0
102; GFX11-NEXT:    s_setpc_b64 s[30:31]
103  %fma = call float @llvm.amdgcn.fma.legacy(float %a, float 2.0, float -1.0)
104  ret float %fma
105}
106
107declare float @llvm.amdgcn.fma.legacy(float, float, float)
108declare float @llvm.fabs.f32(float)
109