LLVM 24.0.0git
KnownFPClass.cpp
Go to the documentation of this file.
1//===- llvm/Support/KnownFPClass.h - Stores known fplcass -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains a class for representing known fpclasses used by
10// computeKnownFPClass.
11//
12//===----------------------------------------------------------------------===//
13
15#include "llvm/ADT/APFloat.h"
18
19using namespace llvm;
20
22 setSignBit(C.isNegative());
23}
24
25/// Return true if it's possible to assume IEEE treatment of input denormals in
26/// \p F for \p Val.
28 return Mode.Input == DenormalMode::IEEE;
29}
30
35
40
45
48 return false;
49
50 // If we know there are no denormals, nothing can be flushed to zero.
52 return true;
53
54 switch (Mode.Input) {
56 return true;
58 // Negative subnormal won't flush to +0
61 default:
62 // Both positive and negative subnormal could flush to +0
63 return false;
64 }
65
66 llvm_unreachable("covered switch over denormal mode");
67}
68
70 DenormalMode Mode) {
71 KnownFPClasses = Src.KnownFPClasses;
72 // If we aren't assuming the source can't be a zero, we don't have to check if
73 // a denormal input could be flushed.
74 if (!Src.isKnownNeverPosZero() && !Src.isKnownNeverNegZero())
75 return;
76
77 // If we know the input can't be a denormal, it can't be flushed to 0.
78 if (Src.isKnownNeverSubnormal())
79 return;
80
81 if (!Src.isKnownNeverPosSubnormal() && Mode != DenormalMode::getIEEE())
83
84 if (!Src.isKnownNeverNegSubnormal() && Mode != DenormalMode::getIEEE()) {
87
88 if (Mode.Input == DenormalMode::PositiveZero ||
89 Mode.Output == DenormalMode::PositiveZero ||
90 Mode.Input == DenormalMode::Dynamic ||
91 Mode.Output == DenormalMode::Dynamic)
93 }
94}
95
97 const KnownFPClass &RHS_, MinMaxKind Kind,
98 DenormalMode Mode) {
99 KnownFPClass KnownLHS = LHS_;
100 KnownFPClass KnownRHS = RHS_;
101
102 bool NeverNaN = KnownLHS.isKnownNeverNaN() || KnownRHS.isKnownNeverNaN();
103 KnownFPClass Known = KnownLHS | KnownRHS;
104
105 // If either operand is not NaN, the result is not NaN.
106 if (NeverNaN &&
107 (Kind == MinMaxKind::minnum || Kind == MinMaxKind::maxnum ||
109 Known.knownNot(fcNan);
110
111 if (Kind == MinMaxKind::maxnum || Kind == MinMaxKind::maximumnum) {
112 if (KnownLHS.isKnownNeverNaN())
113 Known.knownNot(orderedStrictlyLess(KnownLHS.KnownFPClasses));
114 if (KnownRHS.isKnownNeverNaN())
115 Known.knownNot(orderedStrictlyLess(KnownRHS.KnownFPClasses));
116 } else if (Kind == MinMaxKind::maximum) {
117 Known.knownNot(orderedStrictlyLess(KnownLHS.KnownFPClasses) |
119 } else if (Kind == MinMaxKind::minnum || Kind == MinMaxKind::minimumnum) {
120 if (KnownLHS.isKnownNeverNaN())
121 Known.knownNot(orderedStrictlyGreater(KnownLHS.KnownFPClasses));
122 if (KnownRHS.isKnownNeverNaN())
123 Known.knownNot(orderedStrictlyGreater(KnownRHS.KnownFPClasses));
124 } else if (Kind == MinMaxKind::minimum) {
125 Known.knownNot(orderedStrictlyGreater(KnownLHS.KnownFPClasses) |
127 } else
128 llvm_unreachable("unhandled intrinsic");
129
130 // Fixup zero handling if denormals could be returned as a zero.
131 //
132 // As there's no spec for denormal flushing, be conservative with the
133 // treatment of denormals that could be flushed to zero. For older
134 // subtargets on AMDGPU the min/max instructions would not flush the
135 // output and return the original value.
136 //
137 if ((Known.KnownFPClasses & fcZero) != fcNone &&
138 !Known.isKnownNeverSubnormal()) {
139 if (Mode != DenormalMode::getIEEE())
140 Known.KnownFPClasses |= fcZero;
141 }
142
143 if (Known.isKnownNeverNaN()) {
144 if (KnownLHS.getSignBit() && KnownRHS.getSignBit() &&
145 *KnownLHS.getSignBit() == *KnownRHS.getSignBit()) {
146 if (*KnownLHS.getSignBit())
147 Known.signBitMustBeOne();
148 else
149 Known.signBitMustBeZero();
150 } else if ((Kind == MinMaxKind::maximum || Kind == MinMaxKind::minimum ||
151 Kind == MinMaxKind::maximumnum ||
152 Kind == MinMaxKind::minimumnum) ||
153 // FIXME: Should be using logical zero versions
154 ((KnownLHS.isKnownNeverNegZero() ||
155 KnownRHS.isKnownNeverPosZero()) &&
156 (KnownLHS.isKnownNeverPosZero() ||
157 KnownRHS.isKnownNeverNegZero()))) {
158 // Don't take sign bit from NaN operands.
159 if (!KnownLHS.isKnownNeverNaN())
160 KnownLHS.setSignBit(std::nullopt);
161 if (!KnownRHS.isKnownNeverNaN())
162 KnownRHS.setSignBit(std::nullopt);
163 if ((Kind == MinMaxKind::maximum || Kind == MinMaxKind::maximumnum ||
164 Kind == MinMaxKind::maxnum) &&
165 (KnownLHS.getSignBit() == false || KnownRHS.getSignBit() == false))
166 Known.signBitMustBeZero();
167 else if ((Kind == MinMaxKind::minimum || Kind == MinMaxKind::minimumnum ||
168 Kind == MinMaxKind::minnum) &&
169 (KnownLHS.getSignBit() == true || KnownRHS.getSignBit() == true))
170 Known.signBitMustBeOne();
171 }
172 }
173
174 return Known;
175}
176
178 DenormalMode DenormMode) {
180
181 // This is essentially a stronger form of
182 // propagateCanonicalizingSrc. Other "canonicalizing" operations don't
183 // actually have an IR canonicalization guarantee.
184
185 // Canonicalize may flush denormals to zero, so we have to consider the
186 // denormal mode to preserve known-not-0 knowledge.
187 Known.KnownFPClasses = KnownSrc.KnownFPClasses | fcZero | fcQNan;
188
189 // Stronger version of propagateNaN
190 // Canonicalize is guaranteed to quiet signaling nans.
191 if (KnownSrc.isKnownNeverNaN())
192 Known.knownNot(fcNan);
193 else
194 Known.knownNot(fcSNan);
195
196 // FIXME: Missing check of IEEE like types.
197
198 // If the parent function flushes denormals, the canonical output cannot be a
199 // denormal.
200 if (DenormMode == DenormalMode::getIEEE()) {
201 if (KnownSrc.isKnownNever(fcPosZero))
202 Known.knownNot(fcPosZero);
203 if (KnownSrc.isKnownNever(fcNegZero))
204 Known.knownNot(fcNegZero);
205 return Known;
206 }
207
208 if (DenormMode.inputsAreZero() || DenormMode.outputsAreZero())
209 Known.knownNot(fcSubnormal);
210
211 if (DenormMode == DenormalMode::getPreserveSign()) {
212 if (KnownSrc.isKnownNever(fcPosZero | fcPosSubnormal))
213 Known.knownNot(fcPosZero);
214 if (KnownSrc.isKnownNever(fcNegZero | fcNegSubnormal))
215 Known.knownNot(fcNegZero);
216 return Known;
217 }
218
219 if (DenormMode.Input == DenormalMode::PositiveZero ||
220 (DenormMode.Output == DenormalMode::PositiveZero &&
221 DenormMode.Input == DenormalMode::IEEE)) {
222 // -0.0 is not a subnormal and should not be flushed.
223 if (KnownSrc.isKnownNever(fcNegZero))
224 Known.knownNot(fcNegZero);
225
226 if (KnownSrc.isKnownNever(fcPosZero | fcSubnormal))
227 Known.knownNot(fcPosZero);
228 }
229
230 return Known;
231}
232
234 const KnownBits &Bits) {
235 assert(FltSemantics.sizeInBits == Bits.getBitWidth() &&
236 "Bitcast operand has incorrect bit width");
238
239 // Conflicting known bits do not describe a concrete value. Return unknown.
240 if (Bits.hasConflict())
241 return Known;
242
243 // Transfer information from the sign bit.
244 if (Bits.isNonNegative())
245 Known.signBitMustBeZero();
246 else if (Bits.isNegative())
247 Known.signBitMustBeOne();
248
249 if (APFloat::isIEEELikeFP(FltSemantics)) {
250 const unsigned MantissaBits = FltSemantics.precision - 1;
251 const APInt ExponentMask = APInt::getBitsSet(
252 FltSemantics.sizeInBits, MantissaBits, FltSemantics.sizeInBits - 1);
253 const APInt MantissaMask =
254 APInt::getLowBitsSet(FltSemantics.sizeInBits, MantissaBits);
255
256 const bool ExponentKnownAllZeros =
257 (Bits.Zero & ExponentMask) == ExponentMask;
258 const bool ExponentKnownAllOnes = (Bits.One & ExponentMask) == ExponentMask;
259 const bool ExponentKnownNotAllZeros = !(Bits.One & ExponentMask).isZero();
260 const bool ExponentKnownNotAllOnes = !(Bits.Zero & ExponentMask).isZero();
261
262 const bool MantissaKnownAllZeros =
263 (Bits.Zero & MantissaMask) == MantissaMask;
264 const bool MantissaKnownNotAllZeros = !(Bits.One & MantissaMask).isZero();
265
266 // Zero and subnormal require an exponent with all zero bits.
267 if (ExponentKnownNotAllZeros)
268 Known.knownNot(fcZero | fcSubnormal);
269
270 // Infinity and NaN require an exponent with all one bits.
271 if (ExponentKnownNotAllOnes)
272 Known.knownNot(fcInf | fcNan);
273
274 // Normal values have an exponent that is not all zeros or all ones.
275 if (ExponentKnownAllZeros || ExponentKnownAllOnes)
276 Known.knownNot(fcNormal);
277
278 // Zero and infinity require a mantissa with all zero bits.
279 if (MantissaKnownNotAllZeros)
280 Known.knownNot(fcZero | fcInf);
281
282 // Subnormal and NaN require a non-zero mantissa.
283 if (MantissaKnownAllZeros)
284 Known.knownNot(fcSubnormal | fcNan);
285
286 const bool QuietBitKnownSet = Bits.One[MantissaBits - 1];
287 const bool QuietBitKnownClear = Bits.Zero[MantissaBits - 1];
288
289 if (QuietBitKnownSet)
290 Known.knownNot(fcSNan);
291 else if (QuietBitKnownClear)
292 Known.knownNot(fcQNan);
293 }
294
295 return Known;
296}
297
299 KnownBits Known(FltSemantics.sizeInBits);
300 const FPClassTest FPClasses = KnownFPClasses;
301
302 // Return unknown if poison.
303 if (FPClasses == fcNone)
304 return Known;
305
307 Known.setAllConflict();
308
309 if (FPClasses & fcInf)
310 Known = Known.intersectWith(KnownBits::makeConstant(
311 APFloat::getInf(FltSemantics).bitcastToAPInt()));
312
313 if (FPClasses & fcZero)
314 Known = Known.intersectWith(
316
317 Known.Zero.clearSignBit();
318 Known.One.clearSignBit();
319 }
320
321 if (std::optional<bool> Sign = getSignBit()) {
322 if (*Sign)
323 Known.makeNegative();
324 else
325 Known.makeNonNegative();
326 }
327
328 return Known;
329}
330
331// Handle known sign bit and nan cases for fadd.
332static KnownFPClass fadd_impl(const KnownFPClass &KnownLHS,
333 const KnownFPClass &KnownRHS, DenormalMode Mode) {
335
336 // Adding positive and negative infinity produces NaN, but only if both
337 // opposite-sign infinity combinations are possible.
338 if (KnownLHS.isKnownNeverNaN() && KnownRHS.isKnownNeverNaN() &&
339 (KnownLHS.isKnownNever(fcPosInf) || KnownRHS.isKnownNever(fcNegInf)) &&
340 (KnownLHS.isKnownNever(fcNegInf) || KnownRHS.isKnownNever(fcPosInf)))
341 Known.knownNot(fcNan);
342
343 if (KnownLHS.cannotBeOrderedLessThanZero() &&
344 KnownRHS.cannotBeOrderedLessThanZero()) {
346
347 // This can't underflow if one of the operands is known normal.
348 if (KnownLHS.isKnownNever(fcZero | fcPosSubnormal) ||
350 Known.knownNot(fcZero | fcPosSubnormal);
351 }
352
353 if (KnownLHS.cannotBeOrderedGreaterThanZero() &&
356
357 // This can't underflow if one of the operands is known normal.
358 if (KnownLHS.isKnownNever(fcZero | fcNegSubnormal) ||
360 Known.knownNot(fcZero | fcNegSubnormal);
361 }
362
363 return Known;
364}
365
367 const KnownFPClass &KnownRHS,
368 DenormalMode Mode) {
369 KnownFPClass Known = fadd_impl(KnownLHS, KnownRHS, Mode);
370
371 // (fadd x, 0.0) is guaranteed to return +0.0, not -0.0.
372 if ((KnownLHS.isKnownNeverLogicalNegZero(Mode) ||
373 KnownRHS.isKnownNeverLogicalNegZero(Mode)) &&
374 // Make sure output negative denormal can't flush to -0
375 (Mode.Output == DenormalMode::IEEE ||
376 Mode.Output == DenormalMode::PositiveZero))
377 Known.knownNot(fcNegZero);
378
379 return Known;
380}
381
383 DenormalMode Mode) {
384 KnownFPClass Known = fadd(KnownSrc, KnownSrc, Mode);
385
386 // Doubling 0 will give the same 0.
387 if (KnownSrc.isKnownNeverLogicalPosZero(Mode) &&
388 (Mode.Output == DenormalMode::IEEE ||
389 (Mode.Output == DenormalMode::PreserveSign &&
390 KnownSrc.isKnownNeverPosSubnormal()) ||
391 (Mode.Output == DenormalMode::PositiveZero &&
392 KnownSrc.isKnownNeverSubnormal())))
393 Known.knownNot(fcPosZero);
394
395 return Known;
396}
397
399 const KnownFPClass &KnownRHS,
400 DenormalMode Mode) {
401 return fadd(KnownLHS, fneg(KnownRHS), Mode);
402}
403
405 const KnownFPClass &KnownRHS,
406 DenormalMode Mode) {
408
409 // +X * +Y or -X * -Y => +Q
410 // +X * -Y or -X * +Y => -Q
411 Known.propagateXorSign(KnownLHS, KnownRHS);
412
413 // Inf * Y => Inf or NaN
414 if (KnownLHS.isKnownAlways(fcInf | fcNan) ||
415 KnownRHS.isKnownAlways(fcInf | fcNan))
416 Known.knownNot(fcNormal | fcSubnormal | fcZero);
417
418 // 0 * Y => 0 or NaN
419 if (KnownRHS.isKnownAlways(fcZero | fcNan) ||
420 KnownLHS.isKnownAlways(fcZero | fcNan))
421 Known.knownNot(fcNormal | fcSubnormal | fcInf);
422
423 if (!KnownLHS.isKnownNeverNaN() || !KnownRHS.isKnownNeverNaN())
424 return Known;
425
426 // 0 * +/-inf => NaN
427 if ((KnownRHS.isKnownNeverInfinity() ||
428 KnownLHS.isKnownNeverLogicalZero(Mode)) &&
429 (KnownLHS.isKnownNeverInfinity() ||
430 KnownRHS.isKnownNeverLogicalZero(Mode)))
431 Known.knownNot(fcNan);
432
433 return Known;
434}
435
436// TODO: This generalizes to known ranges
438 const APFloat &CRHS, DenormalMode Mode) {
439 // Match denormal scaling pattern, similar to the case in ldexp. If the
440 // constant's exponent is sufficiently large, the result cannot be subnormal.
441
442 const fltSemantics &Flt = CRHS.getSemantics();
443 unsigned Precision = APFloat::semanticsPrecision(Flt);
444 const int MantissaBits = Precision - 1;
445
446 int MinKnownExponent = ilogb(CRHS);
447 bool CannotBeSubnormal = (MinKnownExponent >= MantissaBits);
448
449 KnownFPClass Known = KnownFPClass::fmul(KnownLHS, KnownFPClass(CRHS), Mode);
450 if (CannotBeSubnormal)
451 Known.knownNot(fcSubnormal);
452
453 // Multiply of values <= 1 cannot introduce overflow.
454 if (KnownLHS.isKnownNever(fcInf)) {
455 if (MinKnownExponent < 0)
456 Known.knownNot(fcInf);
457 else if (MinKnownExponent == 0 && CRHS.compareAbsoluteValue(APFloat::getOne(
458 Flt)) == APFloat::cmpEqual)
459 Known.knownNot(fcInf);
460 }
461
462 return Known;
463}
464
466 const KnownFPClass &KnownRHS,
467 DenormalMode Mode) {
469
470 // Only 0/0, Inf/Inf produce NaN.
471 if (KnownLHS.isKnownNeverNaN() && KnownRHS.isKnownNeverNaN() &&
472 (KnownLHS.isKnownNeverInfinity() || KnownRHS.isKnownNeverInfinity()) &&
473 (KnownLHS.isKnownNeverLogicalZero(Mode) ||
474 KnownRHS.isKnownNeverLogicalZero(Mode))) {
475 Known.knownNot(fcNan);
476 }
477
478 // X / -0.0 => -Inf (or NaN)
479 // +X / +Y or -X / -Y => +Q
480 // +X / -Y or -X / +Y => -Q
481 Known.propagateXorSign(KnownLHS, KnownRHS);
482
483 // Normal and subnormal results require two non-zero finite operands.
484 if ((KnownLHS.isKnownNever(fcNegNormal | fcNegSubnormal) &&
488 Known.knownNot(fcNegNormal | fcNegSubnormal);
489 if ((KnownLHS.isKnownNever(fcNegNormal | fcNegSubnormal) &&
493 Known.knownNot(fcPosNormal | fcPosSubnormal);
494
495 // 0 / X => 0 or NaN
496 if (KnownLHS.isKnownAlways(fcZero))
497 Known.knownNot(fcSubnormal | fcNormal | fcInf);
498
499 // X / 0 => NaN or Inf
500 if (KnownRHS.isKnownAlways(fcZero))
501 Known.knownNot(fcFinite);
502
503 return Known;
504}
505
507 DenormalMode Mode) {
508 // X / X is always exactly 1.0 or a NaN.
510
511 if (KnownSrc.isKnownNeverInfOrNaN() && KnownSrc.isKnownNeverLogicalZero(Mode))
512 Known.knownNot(fcNan);
513 else if (KnownSrc.isKnownNever(fcSNan))
514 Known.knownNot(fcSNan);
515
516 return Known;
517}
518
520 const KnownFPClass &KnownRHS,
521 DenormalMode Mode) {
523
524 Known.knownNot(fcInf);
525
526 // Inf REM x and x REM 0 produce NaN.
527 if (KnownLHS.isKnownNeverNaN() && KnownRHS.isKnownNeverNaN() &&
528 KnownLHS.isKnownNeverInfinity() &&
529 KnownRHS.isKnownNeverLogicalZero(Mode)) {
530 Known.knownNot(fcNan);
531 }
532
533 // The sign for frem is the same as the first operand.
534 if (KnownLHS.cannotBeOrderedLessThanZero())
536 if (KnownLHS.cannotBeOrderedGreaterThanZero())
538
539 // See if we can be more aggressive about the sign of 0.
540 if (KnownLHS.isKnownNever(fcNegative))
541 Known.knownNot(fcNegative);
542 if (KnownLHS.isKnownNever(fcPositive))
543 Known.knownNot(fcPositive);
544
545 return Known;
546}
547
549 DenormalMode Mode) {
550 // X % X is always exactly [+-]0.0 or a NaN.
552
553 if (KnownSrc.isKnownNeverInfOrNaN() && KnownSrc.isKnownNeverLogicalZero(Mode))
554 Known.knownNot(fcNan);
555 else if (KnownSrc.isKnownNever(fcSNan))
556 Known.knownNot(fcSNan);
557
558 return Known;
559}
560
562 const KnownFPClass &KnownRHS,
563 const KnownFPClass &KnownAddend,
564 DenormalMode Mode) {
565 KnownFPClass Mul = fmul(KnownLHS, KnownRHS, Mode);
566
567 // FMA differs from the base fmul + fadd handling only in the treatment of -0
568 // results.
569 //
570 // If the multiply is a -0 due to rounding, the final -0 + 0 will be -0,
571 // unlike for a separate fadd.
572 return fadd_impl(Mul, KnownAddend, Mode);
573}
574
576 const KnownFPClass &KnownAddend,
577 DenormalMode Mode) {
578 KnownFPClass Squared = square(KnownSquared, Mode);
579 KnownFPClass Known = fadd_impl(Squared, KnownAddend, Mode);
580
581 // Since we know the squared input must be positive, the add of opposite sign
582 // infinities nan hazard only applies for negative inf.
583 //
584 // TODO: Alternatively to proving addend is not -inf, we could know Squared is
585 // not pinf. Other than the degenerate always-subnormal input case, we can't
586 // prove that without a known range.
587 if (KnownAddend.isKnownNever(fcNegInf | fcNan) && Squared.isKnownNever(fcNan))
588 Known.knownNot(fcNan);
589
590 return Known;
591}
592
595 Known.knownNot(fcNegative);
596
597 Known.propagateNonNaN(KnownSrc);
598
599 if (KnownSrc.cannotBeOrderedLessThanZero()) {
600 // If the source is positive this cannot underflow.
601 Known.knownNot(fcPosZero);
602
603 // Cannot introduce denormal values.
604 Known.knownNot(fcPosSubnormal);
605 }
606
607 // If the source is negative, this cannot overflow to infinity.
608 if (KnownSrc.cannotBeOrderedGreaterThanZero())
609 Known.knownNot(fcPosInf);
610
611 return Known;
612}
613
619
621 DenormalMode Mode) {
623 Known.knownNot(fcNegZero | fcSubnormal);
624
625 if (KnownSrc.isKnownNeverPosInfinity())
626 Known.knownNot(fcPosInf);
627
628 if (KnownSrc.isKnownNeverNaN() && KnownSrc.cannotBeOrderedLessThanZero())
629 Known.knownNot(fcNan);
630
631 if (KnownSrc.isKnownNeverLogicalZero(Mode))
632 Known.knownNot(fcNegInf);
633
634 return Known;
635}
636
638 DenormalMode Mode) {
640 Known.knownNot(fcPosSubnormal);
641
642 if (KnownSrc.isKnownNeverPosInfinity())
643 Known.knownNot(fcPosInf);
644
645 Known.propagateNonSNaN(KnownSrc);
646
647 // Any negative value besides -0 returns a nan.
648 if (KnownSrc.isKnownNeverNaN() && KnownSrc.cannotBeOrderedLessThanZero())
649 Known.knownNot(fcNan);
650
651 // The only negative value that can be returned is -0 for -0 inputs.
653
654 // If the input denormal mode could be PreserveSign, a negative
655 // subnormal input could produce a negative zero output.
656 if (KnownSrc.isKnownNeverLogicalNegZero(Mode))
657 Known.knownNot(fcNegZero);
658
659 return Known;
660}
661
664
665 // Return NaN on infinite inputs.
666 Known.knownNot(fcInf);
667 if (KnownSrc.isKnownNeverNaN() && KnownSrc.isKnownNeverInfinity())
668 Known.knownNot(fcNan);
669
670 return Known;
671}
672
674 return sin(KnownSrc);
675}
676
679
680 // tan never returns Inf (tan(+-Inf) = NaN; tan(finite) = finite).
681 Known.knownNot(fcInf);
682
683 // NaN propagates. tan(+-Inf) is NaN.
684 if (KnownSrc.isKnownNeverNaN() && KnownSrc.isKnownNeverInfinity())
685 Known.knownNot(fcNan);
686
687 return Known;
688}
689
692
693 // sinh is sign-preserving: sinh(x) < 0 iff x < 0.
694 if (KnownSrc.isKnownNever(fcNegative))
695 Known.knownNot(fcNegative);
696
697 Known.propagateNonNaN(KnownSrc);
698
699 return Known;
700}
701
704
705 // cosh(x) >= 1 for all real x; cosh(+-Inf) = +Inf. Never negative,
706 // zero, or subnormal.
707 Known.knownNot(fcNegative | fcZero | fcSubnormal);
708
709 Known.propagateNonNaN(KnownSrc);
710
711 return Known;
712}
713
716
717 // tanh is bounded to (-1, 1), never Inf.
718 Known.knownNot(fcInf);
719
720 // tanh is sign-preserving: tanh(x) < 0 iff x < 0.
721 if (KnownSrc.isKnownNever(fcNegative))
722 Known.knownNot(fcNegative);
723
724 Known.propagateNonNaN(KnownSrc);
725
726 return Known;
727}
728
731
732 // asin is bounded to [-pi/2, pi/2], never Inf.
733 Known.knownNot(fcInf);
734
735 Known.propagateNonSNaN(KnownSrc);
736
737 // asin is sign-preserving for finite arguments.
738 if (KnownSrc.isKnownNever(fcNegFinite))
739 Known.knownNot(fcNegFinite);
740
741 // NaN propagates. asin(x) is also NaN for |x| > 1, so we cannot rule
742 // out NaN without knowing the source is in [-1, 1].
743 return Known;
744}
745
748
749 // acos(x) is bounded to [0, pi] for -1 <= x <= 1, and is never negative,
750 // infinite, or subnormal. The smallest non-zero value occurs when x is
751 // close to 1.0, where acos(x) can be approximated by sqrt(2 * (1 - x)).
752 // Since sqrt cannot produce a subnormal result, we can conclude that
753 // acos(x) will also never produce a subnormal result.
754 Known.knownNot(fcNegative | fcInf | fcSubnormal);
755
756 // acos(x) == +0.0 iff x == +1.0
757 if (KnownSrc.isKnownNever(fcPosNormal))
758 Known.knownNot(fcZero);
759
760 Known.propagateNonSNaN(KnownSrc);
761
762 // NaN propagates. acos(x) is also NaN for |x| > 1, so we cannot rule
763 // out NaN without knowing the source is in [-1, 1].
764 return Known;
765}
766
769
770 // atan is bounded to (-pi/2, pi/2), never Inf. atan(+-Inf) = +-pi/2 (finite).
771 Known.knownNot(fcInf);
772
773 // atan is sign-preserving: atan(x) < 0 iff x < 0.
774 if (KnownSrc.isKnownNever(fcNegative))
775 Known.knownNot(fcNegative);
776
777 Known.propagateNonNaN(KnownSrc);
778
779 return Known;
780}
781
783 const KnownFPClass &KnownX,
784 DenormalMode Mode) {
786
787 // Even though these deductions are correct, we are ignoring the following
788 // potentially erroneous cases:
789 // * atan2(y, inf) is not subnormal
790 // * atan2(inf, x) is not zero or subnormal
791
792 // atan2 result is in (-pi, pi], never Inf.
793 Known.knownNot(fcInf);
794
795 Known.propagateNonNaN(KnownY, KnownX);
796
797 // Negative subnormals could be treated like positive zero.
798 const bool XCannotHavePositiveValue = KnownX.isKnownNever(fcPositive) &&
799 KnownX.isKnownNeverLogicalPosZero(Mode);
800
801 // If x <= -0.0, then |atan2(y, x)| >= pi/2
802 if (XCannotHavePositiveValue)
803 Known.knownNot(fcZero | fcSubnormal);
804
805 return Known;
806}
807
809 const fltSemantics &DstTy,
810 const fltSemantics &SrcTy) {
811 // Infinity, nan and zero propagate from source.
812 KnownFPClass Known = KnownSrc;
813
814 // All subnormal inputs should be in the normal range in the result type.
815 if (APFloat::isRepresentableAsNormalIn(SrcTy, DstTy)) {
816 if (Known.KnownFPClasses & fcPosSubnormal)
817 Known.KnownFPClasses |= fcPosNormal;
818 if (Known.KnownFPClasses & fcNegSubnormal)
819 Known.KnownFPClasses |= fcNegNormal;
820 Known.knownNot(fcSubnormal);
821 }
822
823 // Sign bit of a nan isn't guaranteed.
824 if (!Known.isKnownNeverNaN())
825 Known.setSignBit(std::nullopt);
826
827 return Known;
828}
829
832
833 // Sign should be preserved
834 // TODO: Handle cannot be ordered greater than zero
835 if (KnownSrc.cannotBeOrderedLessThanZero())
837
838 Known.propagateNonNaN(KnownSrc);
839
840 // Infinity needs a range check.
841 return Known;
842}
843
845 bool IsTrunc,
846 bool IsMultiUnitFPType) {
848
849 // Integer results cannot be subnormal.
850 Known.knownNot(fcSubnormal);
851
852 Known.propagateNonNaN(KnownSrc);
853
854 // Pass through infinities, except PPC_FP128 is a special case for
855 // intrinsics other than trunc.
856 if (IsTrunc || !IsMultiUnitFPType) {
857 if (KnownSrc.isKnownNeverPosInfinity())
858 Known.knownNot(fcPosInf);
859 if (KnownSrc.isKnownNeverNegInfinity())
860 Known.knownNot(fcNegInf);
861 }
862
863 // Negative round ups to 0 produce -0
864 if (KnownSrc.isKnownNever(fcPosFinite))
865 Known.knownNot(fcPosFinite);
866 if (KnownSrc.isKnownNever(fcNegFinite))
867 Known.knownNot(fcNegFinite);
868
869 return Known;
870}
871
873 DenormalMode Mode) {
875 Known.knownNot(fcSubnormal);
876
877 if (KnownSrc.isKnownNever(fcNegative))
878 Known.knownNot(fcNegative);
879 else {
880 if (KnownSrc.isKnownNeverLogicalNegZero(Mode))
881 Known.knownNot(fcNegZero);
882 if (KnownSrc.isKnownNever(fcNegInf))
883 Known.knownNot(fcNegInf);
884 }
885
886 if (KnownSrc.isKnownNever(fcPositive))
887 Known.knownNot(fcPositive);
888 else {
889 if (KnownSrc.isKnownNeverLogicalPosZero(Mode))
890 Known.knownNot(fcPosZero);
891 if (KnownSrc.isKnownNever(fcPosInf))
892 Known.knownNot(fcPosInf);
893 }
894
895 Known.propagateNonNaN(KnownSrc);
896 return Known;
897}
898
900 const APInt &ConstantRangeExpMin,
901 const APInt &ConstantRangeExpMax,
902 const fltSemantics &Flt, DenormalMode Mode) {
904 Known.propagateNonNaN(KnownSrc);
905
906 // Sign is preserved, but underflows may produce zeroes.
907 if (KnownSrc.isKnownNever(fcNegative))
908 Known.knownNot(fcNegative);
909 else if (KnownSrc.cannotBeOrderedLessThanZero())
911
912 if (KnownSrc.isKnownNever(fcPositive))
913 Known.knownNot(fcPositive);
914 else if (KnownSrc.cannotBeOrderedGreaterThanZero())
916
917 unsigned Precision = APFloat::semanticsPrecision(Flt);
918 const int MantissaBits = Precision - 1;
919 if (ConstantRangeExpMin.sge(MantissaBits))
920 Known.knownNot(fcSubnormal);
921
922 if (ConstantRangeExpMin.isZero() && ConstantRangeExpMax.isZero()) {
923 // ldexp(x, 0) -> x, so propagate everything.
924 Known.propagateCanonicalizingSrc(KnownSrc, Mode);
925 } else if (ConstantRangeExpMax.isNonPositive()) {
926 // If we know the power is <= 0, can't introduce inf
927 if (KnownSrc.isKnownNeverPosInfinity())
928 Known.knownNot(fcPosInf);
929 if (KnownSrc.isKnownNeverNegInfinity())
930 Known.knownNot(fcNegInf);
931 } else if (ConstantRangeExpMin.isNonNegative()) {
932 // If we know the power is >= 0, can't introduce subnormal or zero
933 if (KnownSrc.isKnownNeverPosSubnormal())
934 Known.knownNot(fcPosSubnormal);
935 if (KnownSrc.isKnownNeverNegSubnormal())
936 Known.knownNot(fcNegSubnormal);
937 if (KnownSrc.isKnownNeverLogicalPosZero(Mode))
938 Known.knownNot(fcPosZero);
939 if (KnownSrc.isKnownNeverLogicalNegZero(Mode))
940 Known.knownNot(fcNegZero);
941 }
942
943 return Known;
944}
945
947 const KnownBits &ExpBits,
948 const fltSemantics &Flt, DenormalMode Mode) {
949 return ldexp(KnownSrc, ExpBits.getSignedMinValue(),
950 ExpBits.getSignedMaxValue(), Flt, Mode);
951}
952
954 const KnownFPClass &KnownRHS) {
956
957 Known.propagateNonSNaN(KnownLHS, KnownRHS);
958
959 // pow may return NaN if one of the arguments is NaN. NaN may be produced from
960 // a non-zero-finite-negative base and a non-integer exponent.
961 if (KnownLHS.isKnownNever(fcNan | fcNegNormal | fcNegSubnormal) &&
962 KnownRHS.isKnownNeverNaN())
963 Known.knownNot(fcNan);
964
965 // We could rule out negative and subnormal results when exponent is known to
966 // never be a normal value, but having either argument being known to never be
967 // normal is unlikely and not worth considering.
968
969 // Only a negative base raised to an odd power returns a negative value.
970 if (KnownLHS.isKnownNever(fcNegative)) {
971 Known.knownNot(fcNegative);
972 } else if (KnownLHS.isKnownNever(fcNegNormal | fcNegSubnormal)) {
973 Known.knownNot(fcNegNormal | fcNegSubnormal);
974 // See if we can also rule out -0.0 or -inf.
975 // Here at least one of -0.0 or -inf is a possible base.
976
977 // pow(-0.0, odd-positive) = -0.0
978 // pow(-inf, odd-negative) = -0.0
979 if ((KnownLHS.isKnownNever(fcNegZero) ||
980 KnownRHS.isKnownNever(fcPosNormal)) &&
981 (KnownLHS.isKnownNever(fcNegInf) || KnownRHS.isKnownNever(fcNegNormal)))
982 Known.knownNot(fcNegZero);
983
984 // pow(-0.0, odd-negative) = -inf
985 // pow(-inf, odd-positive) = -inf
986 if ((KnownLHS.isKnownNever(fcNegZero) ||
987 KnownRHS.isKnownNever(fcNegNormal)) &&
988 (KnownLHS.isKnownNever(fcNegInf) || KnownRHS.isKnownNever(fcPosNormal)))
989 Known.knownNot(fcNegInf);
990 }
991
992 return Known;
993}
994
996 const KnownBits &ExponentKnownBits) {
998 Known.propagateNonNaN(KnownSrc);
999
1000 if (ExponentKnownBits.isZero()) {
1001 // powi(QNaN, 0) returns 1.0, and powi(SNaN, 0) may non-deterministically
1002 // return 1.0 or a NaN.
1003 if (KnownSrc.isKnownNever(fcSNan)) {
1004 Known.knownNot(~fcPosNormal);
1005 return Known;
1006 }
1007
1008 Known.knownNot(~(fcPosNormal | fcNan));
1009 return Known;
1010 }
1011
1012 // Given that exp is an integer, here are the
1013 // ways that powi can return a negative value:
1014 //
1015 // powi(x, exp) --> negative if exp is odd and x is negative.
1016 // powi(-0, exp) --> -inf if exp is negative odd.
1017 // powi(-0, exp) --> -0 if exp is positive odd.
1018 // powi(-inf, exp) --> -0 if exp is negative odd.
1019 // powi(-inf, exp) --> -inf if exp is positive odd.
1020 if (KnownSrc.isKnownNever(fcNegative) || ExponentKnownBits.isEven()) {
1021 Known.knownNot(fcNegative);
1022 } else if (KnownSrc.isKnownNever(fcNegNormal | fcNegSubnormal)) {
1023 Known.knownNot(fcNegNormal | fcNegSubnormal);
1024 // See if we can also rule out -0.0 or -inf.
1025 // Here at least one of -0.0 or -inf is a possible base.
1026
1027 // We already know that ExponentKnownBits.isEven() is false here.
1028 const bool IsKnownNeverOddPositive = ExponentKnownBits.isNegative();
1029 const bool IsKnownNeverOddNegative = ExponentKnownBits.isNonNegative();
1030
1031 // powi(-0.0, odd-positive) = -0.0
1032 // powi(-inf, odd-negative) = -0.0
1033 if ((KnownSrc.isKnownNever(fcNegZero) || IsKnownNeverOddPositive) &&
1034 (KnownSrc.isKnownNever(fcNegInf) || IsKnownNeverOddNegative))
1035 Known.knownNot(fcNegZero);
1036
1037 // powi(-0.0, odd-negative) = -inf
1038 // powi(-inf, odd-positive) = -inf
1039 if ((KnownSrc.isKnownNever(fcNegZero) || IsKnownNeverOddNegative) &&
1040 (KnownSrc.isKnownNever(fcNegInf) || IsKnownNeverOddPositive))
1041 Known.knownNot(fcNegInf);
1042 }
1043
1044 // powi(x, exp) --> inf
1045 // when:
1046 // * powi(inf, exp), exp > 0
1047 // * powi(+/-0, exp), exp < 0
1048 // * powi(finite, exp), |exp| > 1
1049 // * powi(subnormal, -1)
1050 // TODO:
1051 // 1. This simple all or nothing approach. We can do better
1052 // and cover sign/parity and exp > 1 vs exp < -1 separately.
1053 // 2. powi(0/nan, exp), exp > 0 can be refinable
1054 // to fcNan | fcZero | fcPosNormal.
1055 {
1056 APInt MinExp = ExponentKnownBits.getSignedMinValue();
1057 APInt MaxExp = ExponentKnownBits.getSignedMaxValue();
1058
1059 // powi(inf, exp), exp > 0
1060 bool MayInfSrc =
1061 !KnownSrc.isKnownNever(fcInf) && MaxExp.isStrictlyPositive();
1062
1063 // powi(+/-0, exp), exp < 0
1064 bool MayDivByZero = !KnownSrc.isKnownNever(fcZero) && MinExp.isNegative();
1065
1066 // powi(finite, exp), |exp| > 1
1067 bool MayFinite = !KnownSrc.isKnownNever(fcNormal | fcSubnormal);
1068 bool MayAbsExpGT1 = MinExp.slt(-1) || MaxExp.sgt(1);
1069 bool MayFiniteOverflow = MayFinite && MayAbsExpGT1;
1070
1071 // powi(subnormal, -1)
1072 bool MayBeNegOne = ExponentKnownBits.Zero.isZero();
1073 bool MaySubnormInv = !KnownSrc.isKnownNever(fcSubnormal) && MayBeNegOne;
1074
1075 if (!MayInfSrc && !MayDivByZero && !MayFiniteOverflow && !MaySubnormInv)
1076 Known.knownNot(fcInf);
1077 }
1078
1079 return Known;
1080}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static KnownFPClass fadd_impl(const KnownFPClass &KnownLHS, const KnownFPClass &KnownRHS, DenormalMode Mode)
static bool inputDenormalIsIEEE(DenormalMode Mode)
Return true if it's possible to assume IEEE treatment of input denormals in F for Val.
static bool inputDenormalIsIEEEOrPosZero(DenormalMode Mode)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
Definition Lint.cpp:539
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
static LLVM_ABI unsigned int semanticsPrecision(const fltSemantics &)
Definition APFloat.cpp:318
static LLVM_ABI bool isRepresentableAsNormalIn(const fltSemantics &Src, const fltSemantics &Dst)
Definition APFloat.cpp:368
static LLVM_ABI bool isIEEELikeFP(const fltSemantics &)
Definition APFloat.cpp:359
cmpResult compareAbsoluteValue(const APFloat &RHS) const
Definition APFloat.h:1538
const fltSemantics & getSemantics() const
Definition APFloat.h:1591
static APFloat getOne(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative One.
Definition APFloat.h:1192
static APFloat getInf(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Infinity.
Definition APFloat.h:1202
Class for arbitrary precision integers.
Definition APInt.h:78
bool sgt(const APInt &RHS) const
Signed greater than comparison.
Definition APInt.h:1206
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
Definition APInt.h:255
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
Definition APInt.h:377
bool isNegative() const
Determine sign of this APInt.
Definition APInt.h:326
bool isNonPositive() const
Determine if this APInt Value is non-positive (<= 0).
Definition APInt.h:358
bool isStrictlyPositive() const
Determine if this APInt Value is positive.
Definition APInt.h:353
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
Definition APInt.h:331
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
Definition APInt.h:303
bool slt(const APInt &RHS) const
Signed less than comparison.
Definition APInt.h:1135
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
Definition APInt.h:197
bool sge(const APInt &RHS) const
Signed greater or equal comparison.
Definition APInt.h:1242
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
@ Known
Known to have no common set bits.
LLVM_ABI FPClassTest orderedStrictlyGreater(FPClassTest Mask, bool OrderedZeroSign=false)
Returns all FPClasses which are greater than all values in Mask That is, return all classes for which...
int ilogb(const APFloat &Arg)
Returns the exponent of the internal representation of the APFloat.
Definition APFloat.h:1692
LLVM_ABI FPClassTest orderedStrictlyLess(FPClassTest Mask, bool OrderedZeroSign=false)
Returns all FPClasses which are less than all values in Mask That is, return all classes for which th...
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
@ Mul
Product of integers.
Represent subnormal handling kind for floating point instruction inputs and outputs.
DenormalModeKind Input
Denormal treatment kind for floating point instruction inputs in the default floating-point environme...
constexpr bool outputsAreZero() const
Return true if output denormals should be flushed to 0.
@ PreserveSign
The sign of a flushed-to-zero number is preserved in the sign of 0.
@ PositiveZero
Denormals are flushed to positive zero.
@ Dynamic
Denormals have unknown treatment.
@ IEEE
IEEE-754 denormal numbers preserved.
static constexpr DenormalMode getPositiveZero()
constexpr bool inputsAreZero() const
Return true if input denormals must be implicitly treated as 0.
static constexpr DenormalMode getPreserveSign()
DenormalModeKind Output
Denormal flushing mode for floating point instruction results in the default floating point environme...
static constexpr DenormalMode getIEEE()
static KnownBits makeConstant(const APInt &C)
Create known bits from a known constant.
Definition KnownBits.h:315
bool isNonNegative() const
Returns true if this value is known to be non-negative.
Definition KnownBits.h:106
bool isZero() const
Returns true if value is all zero.
Definition KnownBits.h:78
APInt getSignedMaxValue() const
Return the maximal signed value possible given these KnownBits.
Definition KnownBits.h:152
bool isEven() const
Return if the value is known even (the low bit is 0).
Definition KnownBits.h:162
bool isNegative() const
Returns true if this value is known to be negative.
Definition KnownBits.h:103
APInt getSignedMinValue() const
Return the minimal signed value possible given these KnownBits.
Definition KnownBits.h:136
bool isKnownNeverInfOrNaN() const
Return true if it's known this can never be an infinity or nan.
FPClassTest KnownFPClasses
Floating-point classes the value could be one of.
bool isKnownNeverInfinity() const
Return true if it's known this can never be an infinity.
KnownFPClass(FPClassTest Known=fcAllFlags, std::optional< bool > Sign={})
bool cannotBeOrderedGreaterThanZero() const
Return true if we can prove that the analyzed floating-point value is either NaN or never greater tha...
static LLVM_ABI KnownFPClass sin(const KnownFPClass &Src)
Report known values for sin.
static LLVM_ABI KnownFPClass frem(const KnownFPClass &LHS, const KnownFPClass &RHS, DenormalMode Mode=DenormalMode::getDynamic())
Report known values for frem.
static LLVM_ABI KnownFPClass fdiv_self(const KnownFPClass &Src, DenormalMode Mode=DenormalMode::getDynamic())
Report known values for fdiv x, x.
static constexpr FPClassTest OrderedGreaterThanZeroMask
static constexpr FPClassTest OrderedLessThanZeroMask
static LLVM_ABI KnownFPClass fmul(const KnownFPClass &LHS, const KnownFPClass &RHS, DenormalMode Mode=DenormalMode::getDynamic())
Report known values for fmul.
static LLVM_ABI KnownFPClass fadd_self(const KnownFPClass &Src, DenormalMode Mode=DenormalMode::getDynamic())
Report known values for fadd x, x.
bool isKnownNeverZero() const
Return true if it's known this can never be a zero.
static KnownFPClass square(const KnownFPClass &Src, DenormalMode Mode=DenormalMode::getDynamic())
static LLVM_ABI KnownFPClass fsub(const KnownFPClass &LHS, const KnownFPClass &RHS, DenormalMode Mode=DenormalMode::getDynamic())
Report known values for fsub.
bool isKnownNeverSubnormal() const
Return true if it's known this can never be a subnormal.
bool isKnownAlways(FPClassTest Mask) const
static LLVM_ABI KnownFPClass canonicalize(const KnownFPClass &Src, DenormalMode DenormMode=DenormalMode::getDynamic())
Apply the canonicalize intrinsic to this value.
LLVM_ABI bool isKnownNeverLogicalZero(DenormalMode Mode) const
Return true if it's known this can never be interpreted as a zero.
static LLVM_ABI KnownFPClass log(const KnownFPClass &Src, DenormalMode Mode=DenormalMode::getDynamic())
Propagate known class for log/log2/log10.
static LLVM_ABI KnownFPClass atan2(const KnownFPClass &LHS, const KnownFPClass &RHS, DenormalMode Mode=DenormalMode::getDynamic())
Report known values for atan2.
static LLVM_ABI KnownFPClass atan(const KnownFPClass &Src)
Report known values for atan.
LLVM_ABI void propagateDenormal(const KnownFPClass &Src, DenormalMode Mode)
Propagate knowledge from a source value that could be a denormal or zero.
static LLVM_ABI KnownFPClass fdiv(const KnownFPClass &LHS, const KnownFPClass &RHS, DenormalMode Mode=DenormalMode::getDynamic())
Report known values for fdiv.
static LLVM_ABI KnownFPClass roundToIntegral(const KnownFPClass &Src, bool IsTrunc, bool IsMultiUnitFPType)
Propagate known class for rounding intrinsics (trunc, floor, ceil, rint, nearbyint,...
static LLVM_ABI KnownFPClass cos(const KnownFPClass &Src)
Report known values for cos.
static LLVM_ABI KnownFPClass cosh(const KnownFPClass &Src)
Report known values for cosh.
static LLVM_ABI KnownFPClass minMaxLike(const KnownFPClass &LHS, const KnownFPClass &RHS, MinMaxKind Kind, DenormalMode DenormMode=DenormalMode::getDynamic())
bool isKnownNeverNegInfinity() const
Return true if it's known this can never be -infinity.
bool isKnownNeverNegSubnormal() const
Return true if it's known this can never be a negative subnormal.
bool isKnownNeverPosZero() const
Return true if it's known this can never be a literal positive zero.
static LLVM_ABI KnownFPClass exp(const KnownFPClass &Src)
Report known values for exp, exp2 and exp10.
static LLVM_ABI KnownFPClass frexp_mant(const KnownFPClass &Src, DenormalMode Mode=DenormalMode::getDynamic())
Propagate known class for mantissa component of frexp.
static LLVM_ABI KnownFPClass asin(const KnownFPClass &Src)
Report known values for asin.
bool isKnownNeverNaN() const
Return true if it's known this can never be a nan.
bool isKnownNever(FPClassTest Mask) const
Return true if it's known this can never be one of the mask entries.
std::optional< bool > getSignBit() const
std::nullopt if the sign bit is unknown, true if the sign bit is definitely set or false if the sign ...
static LLVM_ABI KnownFPClass fpext(const KnownFPClass &KnownSrc, const fltSemantics &DstTy, const fltSemantics &SrcTy)
Propagate known class for fpext.
bool isKnownNeverNegZero() const
Return true if it's known this can never be a negative zero.
static LLVM_ABI KnownFPClass fma(const KnownFPClass &LHS, const KnownFPClass &RHS, const KnownFPClass &Addend, DenormalMode Mode=DenormalMode::getDynamic())
Report known values for fma.
static LLVM_ABI KnownFPClass tan(const KnownFPClass &Src)
Report known values for tan.
LLVM_ABI KnownBits toKnownBits(const fltSemantics &FltSemantics) const
Report known bits for a float with provided semantics.
static LLVM_ABI KnownFPClass fptrunc(const KnownFPClass &KnownSrc)
Propagate known class for fptrunc.
bool cannotBeOrderedLessThanZero() const
Return true if we can prove that the analyzed floating-point value is either NaN or never less than -...
LLVM_ABI void propagateCanonicalizingSrc(const KnownFPClass &Src, DenormalMode Mode)
Report known classes if Src is evaluated through a potentially canonicalizing operation.
static LLVM_ABI KnownFPClass sqrt(const KnownFPClass &Src, DenormalMode Mode=DenormalMode::getDynamic())
Propagate known class for sqrt.
LLVM_ABI bool isKnownNeverLogicalPosZero(DenormalMode Mode) const
Return true if it's known this can never be interpreted as a positive zero.
bool isKnownNeverPosInfinity() const
Return true if it's known this can never be +infinity.
static LLVM_ABI KnownFPClass fadd(const KnownFPClass &LHS, const KnownFPClass &RHS, DenormalMode Mode=DenormalMode::getDynamic())
Report known values for fadd.
LLVM_ABI bool isKnownNeverLogicalNegZero(DenormalMode Mode) const
Return true if it's known this can never be interpreted as a negative zero.
static LLVM_ABI KnownFPClass bitcast(const fltSemantics &FltSemantics, const KnownBits &Bits)
Report known values for a bitcast into a float with provided semantics.
static LLVM_ABI KnownFPClass fma_square(const KnownFPClass &Squared, const KnownFPClass &Addend, DenormalMode Mode=DenormalMode::getDynamic())
Report known values for fma squared, squared, addend.
static LLVM_ABI KnownFPClass acos(const KnownFPClass &Src)
Report known values for acos.
static LLVM_ABI KnownFPClass frem_self(const KnownFPClass &Src, DenormalMode Mode=DenormalMode::getDynamic())
Report known values for frem x, x.
static LLVM_ABI KnownFPClass powi(const KnownFPClass &Src, const KnownBits &N)
Propagate known class for powi.
void propagateNonNaN(const KnownFPClass &Src)
static LLVM_ABI KnownFPClass pow(const KnownFPClass &LHS, const KnownFPClass &RHS)
Propagate known class for pow.
static LLVM_ABI KnownFPClass ldexp(const KnownFPClass &Src, const APInt &ConstantRangeMin, const APInt &ConstantRangeMax, const fltSemantics &Flt, DenormalMode Mode=DenormalMode::getDynamic())
Propagate known class for ldexp, assuming the exponent is known to be within [ConstantRangeMin,...
void setSignBit(std::optional< bool > Sign)
static LLVM_ABI KnownFPClass sinh(const KnownFPClass &Src)
Report known values for sinh.
bool isKnownNeverPosSubnormal() const
Return true if it's known this can never be a positive subnormal.
static LLVM_ABI KnownFPClass tanh(const KnownFPClass &Src)
Report known values for tanh.
unsigned int sizeInBits
Definition APFloat.h:1037
unsigned int precision
Definition APFloat.h:1034