File: arm64-fmadd.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (243 lines) | stat: -rw-r--r-- 8,287 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=arm64-eabi < %s | FileCheck %s

define float @fma32(float %a, float %b, float %c) nounwind readnone ssp {
; CHECK-LABEL: fma32:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fmadd s0, s0, s1, s2
; CHECK-NEXT:    ret
entry:
  %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c)
  ret float %0
}

define float @fnma32(float %a, float %b, float %c) nounwind readnone ssp {
; CHECK-LABEL: fnma32:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fnmadd s0, s0, s1, s2
; CHECK-NEXT:    ret
entry:
  %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c)
  %mul = fmul float %0, -1.000000e+00
  ret float %mul
}

define float @fms32(float %a, float %b, float %c) nounwind readnone ssp {
; CHECK-LABEL: fms32:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fmsub s0, s0, s1, s2
; CHECK-NEXT:    ret
entry:
  %mul = fmul float %b, -1.000000e+00
  %0 = tail call float @llvm.fma.f32(float %a, float %mul, float %c)
  ret float %0
}

define float @fms32_com(float %a, float %b, float %c) nounwind readnone ssp {
; CHECK-LABEL: fms32_com:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fmsub s0, s1, s0, s2
; CHECK-NEXT:    ret
entry:
  %mul = fmul float %b, -1.000000e+00
  %0 = tail call float @llvm.fma.f32(float %mul, float %a, float %c)
  ret float %0
}

define float @fnms32(float %a, float %b, float %c) nounwind readnone ssp {
; CHECK-LABEL: fnms32:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fnmsub s0, s0, s1, s2
; CHECK-NEXT:    ret
entry:
  %mul = fmul float %c, -1.000000e+00
  %0 = tail call float @llvm.fma.f32(float %a, float %b, float %mul)
  ret float %0
}

define double @fma64(double %a, double %b, double %c) nounwind readnone ssp {
; CHECK-LABEL: fma64:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fmadd d0, d0, d1, d2
; CHECK-NEXT:    ret
entry:
  %0 = tail call double @llvm.fma.f64(double %a, double %b, double %c)
  ret double %0
}

define double @fnma64(double %a, double %b, double %c) nounwind readnone ssp {
; CHECK-LABEL: fnma64:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fnmadd d0, d0, d1, d2
; CHECK-NEXT:    ret
entry:
  %0 = tail call double @llvm.fma.f64(double %a, double %b, double %c)
  %mul = fmul double %0, -1.000000e+00
  ret double %mul
}

define double @fms64(double %a, double %b, double %c) nounwind readnone ssp {
; CHECK-LABEL: fms64:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fmsub d0, d0, d1, d2
; CHECK-NEXT:    ret
entry:
  %mul = fneg double %b
  %0 = tail call double @llvm.fma.f64(double %a, double %mul, double %c)
  ret double %0
}

define double @fms64_com(double %a, double %b, double %c) nounwind readnone ssp {
; CHECK-LABEL: fms64_com:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fmsub d0, d1, d0, d2
; CHECK-NEXT:    ret
entry:
  %mul = fneg double %b
  %0 = tail call double @llvm.fma.f64(double %mul, double %a, double %c)
  ret double %0
}

define double @fnms64(double %a, double %b, double %c) nounwind readnone ssp {
; CHECK-LABEL: fnms64:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fnmsub d0, d0, d1, d2
; CHECK-NEXT:    ret
entry:
  %mul = fneg double %c
  %0 = tail call double @llvm.fma.f64(double %a, double %b, double %mul)
  ret double %0
}

define float @fma32_strict(float %a, float %b, float %c) nounwind readnone ssp {
; CHECK-LABEL: fma32_strict:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fmadd s0, s0, s1, s2
; CHECK-NEXT:    ret
entry:
  %0 = tail call float @llvm.experimental.constrained.fma.f32(float %a, float %b, float %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
  ret float %0
}

define float @fnma32_strict(float %a, float %b, float %c) nounwind readnone ssp {
; CHECK-LABEL: fnma32_strict:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fnmadd s0, s0, s1, s2
; CHECK-NEXT:    ret
entry:
  %0 = tail call float @llvm.experimental.constrained.fma.f32(float %a, float %b, float %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
  %neg = fneg float %0
  ret float %neg
}

define float @fms32_strict(float %a, float %b, float %c) nounwind readnone ssp {
; CHECK-LABEL: fms32_strict:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fmsub s0, s0, s1, s2
; CHECK-NEXT:    ret
entry:
  %neg = fneg float %b
  %0 = tail call float @llvm.experimental.constrained.fma.f32(float %a, float %neg, float %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
  ret float %0
}

define float @fms32_com_strict(float %a, float %b, float %c) nounwind readnone ssp {
; CHECK-LABEL: fms32_com_strict:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fmsub s0, s0, s1, s2
; CHECK-NEXT:    ret
entry:
  %neg = fneg float %b
  %0 = tail call float @llvm.experimental.constrained.fma.f32(float %neg, float %a, float %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
  ret float %0
}

define float @fnms32_strict(float %a, float %b, float %c) nounwind readnone ssp {
; CHECK-LABEL: fnms32_strict:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fnmsub s0, s0, s1, s2
; CHECK-NEXT:    ret
entry:
  %neg = fneg float %c
  %0 = tail call float @llvm.experimental.constrained.fma.f32(float %a, float %b, float %neg, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
  ret float %0
}

define double @fma64_strict(double %a, double %b, double %c) nounwind readnone ssp {
; CHECK-LABEL: fma64_strict:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fmadd d0, d0, d1, d2
; CHECK-NEXT:    ret
entry:
  %0 = tail call double @llvm.experimental.constrained.fma.f64(double %a, double %b, double %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
  ret double %0
}

define double @fnma64_strict(double %a, double %b, double %c) nounwind readnone ssp {
; CHECK-LABEL: fnma64_strict:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fnmadd d0, d0, d1, d2
; CHECK-NEXT:    ret
entry:
  %0 = tail call double @llvm.experimental.constrained.fma.f64(double %a, double %b, double %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
  %neg = fneg double %0
  ret double %neg
}

define double @fms64_strict(double %a, double %b, double %c) nounwind readnone ssp {
; CHECK-LABEL: fms64_strict:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fmsub d0, d0, d1, d2
; CHECK-NEXT:    ret
entry:
  %neg = fneg double %b
  %0 = tail call double @llvm.experimental.constrained.fma.f64(double %a, double %neg, double %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
  ret double %0
}

define double @fms64_com_strict(double %a, double %b, double %c) nounwind readnone ssp {
; CHECK-LABEL: fms64_com_strict:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fmsub d0, d0, d1, d2
; CHECK-NEXT:    ret
entry:
  %neg = fneg double %b
  %0 = tail call double @llvm.experimental.constrained.fma.f64(double %neg, double %a, double %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
  ret double %0
}

define double @fnms64_strict(double %a, double %b, double %c) nounwind readnone ssp {
; CHECK-LABEL: fnms64_strict:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fnmsub d0, d0, d1, d2
; CHECK-NEXT:    ret
entry:
  %neg = fneg double %c
  %0 = tail call double @llvm.experimental.constrained.fma.f64(double %a, double %b, double %neg, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
  ret double %0
}

; This would crash while trying getNegatedExpression().

define float @negated_constant(float %x) {
; CHECK-LABEL: negated_constant:
; CHECK:       // %bb.0:
; CHECK-NEXT:    mov w8, #-1037565952
; CHECK-NEXT:    fmov s1, w8
; CHECK-NEXT:    mov w8, #1109917696
; CHECK-NEXT:    fmul s1, s0, s1
; CHECK-NEXT:    fmov s2, w8
; CHECK-NEXT:    fmadd s0, s0, s2, s1
; CHECK-NEXT:    ret
  %m = fmul float %x, 42.0
  %fma = call nsz float @llvm.fma.f32(float %x, float -42.0, float %m)
  %nfma = fneg float %fma
  ret float %nfma
}

attributes #0 = { strictfp }

declare float @llvm.fma.f32(float, float, float) nounwind readnone
declare double @llvm.fma.f64(double, double, double) nounwind readnone
declare float @llvm.experimental.constrained.fma.f32(float, float, float, metadata, metadata)
declare double @llvm.experimental.constrained.fma.f64(double, double, double, metadata, metadata)