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 : KnownFPClassesValue(C.classify()) {
23 setSignBit(C.isNegative());
24}
25
26/// Return true if it's possible to assume IEEE treatment of input denormals in
27/// \p F for \p Val.
29 return Mode.Input == DenormalMode::IEEE;
30}
31
36
41
46
49 return false;
50
51 // If we know there are no denormals, nothing can be flushed to zero.
53 return true;
54
55 switch (Mode.Input) {
57 return true;
59 // Negative subnormal won't flush to +0
62 default:
63 // Both positive and negative subnormal could flush to +0
64 return false;
65 }
66
67 llvm_unreachable("covered switch over denormal mode");
68}
69
71 DenormalMode Mode) {
72 setKnownFPClasses(Src.getKnownFPClasses());
73 // If we aren't assuming the source can't be a zero, we don't have to check if
74 // a denormal input could be flushed.
75 if (!Src.isKnownNeverPosZero() && !Src.isKnownNeverNegZero())
76 return;
77
78 // If we know the input can't be a denormal, it can't be flushed to 0.
79 if (Src.isKnownNeverSubnormal())
80 return;
81
82 if (!Src.isKnownNeverPosSubnormal() && Mode != DenormalMode::getIEEE())
84
85 if (!Src.isKnownNeverNegSubnormal() && Mode != DenormalMode::getIEEE()) {
88
89 if (Mode.Input == DenormalMode::PositiveZero ||
90 Mode.Output == DenormalMode::PositiveZero ||
91 Mode.Input == DenormalMode::Dynamic ||
92 Mode.Output == DenormalMode::Dynamic)
94 }
95}
96
98 const KnownFPClass &RHS_, MinMaxKind Kind,
99 DenormalMode Mode) {
100 KnownFPClass KnownLHS = LHS_;
101 KnownFPClass KnownRHS = RHS_;
102
103 bool NeverNaN = KnownLHS.isKnownNeverNaN() || KnownRHS.isKnownNeverNaN();
104 KnownFPClass Known = KnownLHS | KnownRHS;
105
106 // If either operand is not NaN, the result is not NaN.
107 if (NeverNaN &&
108 (Kind == MinMaxKind::minnum || Kind == MinMaxKind::maxnum ||
110 Known.knownNot(fcNan);
111
112 if (Kind == MinMaxKind::maxnum || Kind == MinMaxKind::maximumnum) {
113 if (KnownLHS.isKnownNeverNaN())
114 Known.knownNot(orderedStrictlyLess(KnownLHS.getKnownFPClasses()));
115 if (KnownRHS.isKnownNeverNaN())
116 Known.knownNot(orderedStrictlyLess(KnownRHS.getKnownFPClasses()));
117 } else if (Kind == MinMaxKind::maximum) {
118 Known.knownNot(orderedStrictlyLess(KnownLHS.getKnownFPClasses()) |
120 } else if (Kind == MinMaxKind::minnum || Kind == MinMaxKind::minimumnum) {
121 if (KnownLHS.isKnownNeverNaN())
122 Known.knownNot(orderedStrictlyGreater(KnownLHS.getKnownFPClasses()));
123 if (KnownRHS.isKnownNeverNaN())
124 Known.knownNot(orderedStrictlyGreater(KnownRHS.getKnownFPClasses()));
125 } else if (Kind == MinMaxKind::minimum) {
126 Known.knownNot(orderedStrictlyGreater(KnownLHS.getKnownFPClasses()) |
128 } else
129 llvm_unreachable("unhandled intrinsic");
130
131 // Fixup zero handling if denormals could be returned as a zero.
132 //
133 // As there's no spec for denormal flushing, be conservative with the
134 // treatment of denormals that could be flushed to zero. For older
135 // subtargets on AMDGPU the min/max instructions would not flush the
136 // output and return the original value.
137 //
138 if ((Known.getKnownFPClasses() & fcZero) != fcNone &&
139 !Known.isKnownNeverSubnormal()) {
140 if (Mode != DenormalMode::getIEEE())
141 Known.setKnownFPClasses(Known.getKnownFPClasses() | fcZero);
142 }
143
144 if (Known.isKnownNeverNaN()) {
145 if (KnownLHS.getSignBit() && KnownRHS.getSignBit() &&
146 *KnownLHS.getSignBit() == *KnownRHS.getSignBit()) {
147 if (*KnownLHS.getSignBit())
148 Known.signBitMustBeOne();
149 else
150 Known.signBitMustBeZero();
151 } else if ((Kind == MinMaxKind::maximum || Kind == MinMaxKind::minimum ||
152 Kind == MinMaxKind::maximumnum ||
153 Kind == MinMaxKind::minimumnum) ||
154 // FIXME: Should be using logical zero versions
155 ((KnownLHS.isKnownNeverNegZero() ||
156 KnownRHS.isKnownNeverPosZero()) &&
157 (KnownLHS.isKnownNeverPosZero() ||
158 KnownRHS.isKnownNeverNegZero()))) {
159 // Don't take sign bit from NaN operands.
160 if (!KnownLHS.isKnownNeverNaN())
161 KnownLHS.setSignBit(std::nullopt);
162 if (!KnownRHS.isKnownNeverNaN())
163 KnownRHS.setSignBit(std::nullopt);
164 if ((Kind == MinMaxKind::maximum || Kind == MinMaxKind::maximumnum ||
165 Kind == MinMaxKind::maxnum) &&
166 (KnownLHS.getSignBit() == false || KnownRHS.getSignBit() == false))
167 Known.signBitMustBeZero();
168 else if ((Kind == MinMaxKind::minimum || Kind == MinMaxKind::minimumnum ||
169 Kind == MinMaxKind::minnum) &&
170 (KnownLHS.getSignBit() == true || KnownRHS.getSignBit() == true))
171 Known.signBitMustBeOne();
172 }
173 }
174
175 return Known;
176}
177
179 DenormalMode DenormMode) {
181
182 // This is essentially a stronger form of
183 // propagateCanonicalizingSrc. Other "canonicalizing" operations don't
184 // actually have an IR canonicalization guarantee.
185
186 // Canonicalize may flush denormals to zero, so we have to consider the
187 // denormal mode to preserve known-not-0 knowledge.
188 Known.setKnownFPClasses(KnownSrc.getKnownFPClasses() | fcZero | fcQNan);
189
190 // Stronger version of propagateNaN
191 // Canonicalize is guaranteed to quiet signaling nans.
192 if (KnownSrc.isKnownNeverNaN())
193 Known.knownNot(fcNan);
194 else
195 Known.knownNot(fcSNan);
196
197 // FIXME: Missing check of IEEE like types.
198
199 // If the parent function flushes denormals, the canonical output cannot be a
200 // denormal.
201 if (DenormMode == DenormalMode::getIEEE()) {
202 if (KnownSrc.isKnownNever(fcPosZero))
203 Known.knownNot(fcPosZero);
204 if (KnownSrc.isKnownNever(fcNegZero))
205 Known.knownNot(fcNegZero);
206 return Known;
207 }
208
209 if (DenormMode.inputsAreZero() || DenormMode.outputsAreZero())
210 Known.knownNot(fcSubnormal);
211
212 if (DenormMode == DenormalMode::getPreserveSign()) {
213 if (KnownSrc.isKnownNever(fcPosZero | fcPosSubnormal))
214 Known.knownNot(fcPosZero);
215 if (KnownSrc.isKnownNever(fcNegZero | fcNegSubnormal))
216 Known.knownNot(fcNegZero);
217 return Known;
218 }
219
220 if (DenormMode.Input == DenormalMode::PositiveZero ||
221 (DenormMode.Output == DenormalMode::PositiveZero &&
222 DenormMode.Input == DenormalMode::IEEE)) {
223 // -0.0 is not a subnormal and should not be flushed.
224 if (KnownSrc.isKnownNever(fcNegZero))
225 Known.knownNot(fcNegZero);
226
227 if (KnownSrc.isKnownNever(fcPosZero | fcSubnormal))
228 Known.knownNot(fcPosZero);
229 }
230
231 return Known;
232}
233
235 const KnownBits &Bits) {
236 assert(FltSemantics.sizeInBits == Bits.getBitWidth() &&
237 "Bitcast operand has incorrect bit width");
239
240 // Conflicting known bits do not describe a concrete value. Return unknown.
241 if (Bits.hasConflict())
242 return Known;
243
244 // Return unknown for types we have not validated.
245 auto IsSupported = [](const fltSemantics &Semantics) {
246 switch (APFloat::SemanticsToEnum(Semantics)) {
253 return true;
254 default:
255 return false;
256 }
257 };
258 if (!IsSupported(FltSemantics))
259 return Known;
260
261 // Transfer information from the sign bit.
262 if (Bits.isNonNegative())
263 Known.signBitMustBeZero();
264 else if (Bits.isNegative())
265 Known.signBitMustBeOne();
266
267 if (APFloat::isIEEELikeFP(FltSemantics)) {
268 const unsigned MantissaBits = FltSemantics.precision - 1;
269 const APInt ExponentMask = APInt::getBitsSet(
270 FltSemantics.sizeInBits, MantissaBits, FltSemantics.sizeInBits - 1);
271 const APInt MantissaMask =
272 APInt::getLowBitsSet(FltSemantics.sizeInBits, MantissaBits);
273
274 const bool ExponentKnownAllZeros =
275 (Bits.Zero & ExponentMask) == ExponentMask;
276 const bool ExponentKnownAllOnes = (Bits.One & ExponentMask) == ExponentMask;
277 const bool ExponentKnownNotAllZeros = !(Bits.One & ExponentMask).isZero();
278 const bool ExponentKnownNotAllOnes = !(Bits.Zero & ExponentMask).isZero();
279
280 const bool MantissaKnownAllZeros =
281 (Bits.Zero & MantissaMask) == MantissaMask;
282 const bool MantissaKnownNotAllZeros = !(Bits.One & MantissaMask).isZero();
283
284 // Zero and subnormal require an exponent with all zero bits.
285 if (ExponentKnownNotAllZeros)
286 Known.knownNot(fcZero | fcSubnormal);
287
288 // Infinity and NaN require an exponent with all one bits.
289 if (ExponentKnownNotAllOnes)
290 Known.knownNot(fcInf | fcNan);
291
292 // Normal values have an exponent that is not all zeros or all ones.
293 if (ExponentKnownAllZeros || ExponentKnownAllOnes)
294 Known.knownNot(fcNormal);
295
296 // Zero and infinity require a mantissa with all zero bits.
297 if (MantissaKnownNotAllZeros)
298 Known.knownNot(fcZero | fcInf);
299
300 // Subnormal and NaN require a non-zero mantissa.
301 if (MantissaKnownAllZeros)
302 Known.knownNot(fcSubnormal | fcNan);
303
304 const bool QuietBitKnownSet = Bits.One[MantissaBits - 1];
305 const bool QuietBitKnownClear = Bits.Zero[MantissaBits - 1];
306
307 if (QuietBitKnownSet)
308 Known.knownNot(fcSNan);
309 else if (QuietBitKnownClear)
310 Known.knownNot(fcQNan);
311 }
312
313 return Known;
314}
315
317 KnownBits Known(FltSemantics.sizeInBits);
318 const FPClassTest FPClasses = getKnownFPClasses();
319
320 // Return unknown if poison.
321 if (FPClasses == fcNone)
322 return Known;
323
324 // Return unknown for types we have not validated.
325 auto IsSupported = [](const fltSemantics &Semantics) {
326 switch (APFloat::SemanticsToEnum(Semantics)) {
333 return true;
334 default:
335 return false;
336 }
337 };
338 if (!IsSupported(FltSemantics))
339 return Known;
340
342 Known.setAllConflict();
343
344 if (FPClasses & fcInf)
345 Known = Known.intersectWith(KnownBits::makeConstant(
346 APFloat::getInf(FltSemantics).bitcastToAPInt()));
347
348 if (FPClasses & fcZero)
349 Known = Known.intersectWith(
351
352 Known.Zero.clearSignBit();
353 Known.One.clearSignBit();
354 }
355
356 if (std::optional<bool> Sign = getSignBit()) {
357 if (*Sign)
358 Known.makeNegative();
359 else
360 Known.makeNonNegative();
361 }
362
363 return Known;
364}
365
366// Handle known sign bit and nan cases for fadd.
367static KnownFPClass fadd_impl(const KnownFPClass &KnownLHS,
368 const KnownFPClass &KnownRHS, DenormalMode Mode) {
370
371 // Adding positive and negative infinity produces NaN, but only if both
372 // opposite-sign infinity combinations are possible.
373 if (KnownLHS.isKnownNeverNaN() && KnownRHS.isKnownNeverNaN() &&
374 (KnownLHS.isKnownNever(fcPosInf) || KnownRHS.isKnownNever(fcNegInf)) &&
375 (KnownLHS.isKnownNever(fcNegInf) || KnownRHS.isKnownNever(fcPosInf)))
376 Known.knownNot(fcNan);
377
378 if (KnownLHS.cannotBeOrderedLessThanZero() &&
379 KnownRHS.cannotBeOrderedLessThanZero()) {
381
382 // This can't underflow if one of the operands is known normal.
383 if (KnownLHS.isKnownNever(fcZero | fcPosSubnormal) ||
385 Known.knownNot(fcZero | fcPosSubnormal);
386 }
387
388 if (KnownLHS.cannotBeOrderedGreaterThanZero() &&
391
392 // This can't underflow if one of the operands is known normal.
393 if (KnownLHS.isKnownNever(fcZero | fcNegSubnormal) ||
395 Known.knownNot(fcZero | fcNegSubnormal);
396 }
397
398 return Known;
399}
400
402 const KnownFPClass &KnownRHS,
403 DenormalMode Mode) {
404 KnownFPClass Known = fadd_impl(KnownLHS, KnownRHS, Mode);
405
406 // (fadd x, 0.0) is guaranteed to return +0.0, not -0.0.
407 if ((KnownLHS.isKnownNeverLogicalNegZero(Mode) ||
408 KnownRHS.isKnownNeverLogicalNegZero(Mode)) &&
409 // Make sure output negative denormal can't flush to -0
410 (Mode.Output == DenormalMode::IEEE ||
411 Mode.Output == DenormalMode::PositiveZero))
412 Known.knownNot(fcNegZero);
413
414 Known.propagateNonSNaN(KnownLHS, KnownRHS);
415
416 return Known;
417}
418
420 DenormalMode Mode) {
421 KnownFPClass Known = fadd(KnownSrc, KnownSrc, Mode);
422
423 // Doubling 0 will give the same 0.
424 if (KnownSrc.isKnownNeverLogicalPosZero(Mode) &&
425 (Mode.Output == DenormalMode::IEEE ||
426 (Mode.Output == DenormalMode::PreserveSign &&
427 KnownSrc.isKnownNeverPosSubnormal()) ||
428 (Mode.Output == DenormalMode::PositiveZero &&
429 KnownSrc.isKnownNeverSubnormal())))
430 Known.knownNot(fcPosZero);
431
432 return Known;
433}
434
436 const KnownFPClass &KnownRHS,
437 DenormalMode Mode) {
438 return fadd(KnownLHS, fneg(KnownRHS), Mode);
439}
440
442 const KnownFPClass &KnownRHS,
443 DenormalMode Mode) {
445
446 Known.propagateNonSNaN(KnownLHS, KnownRHS);
447
448 // +X * +Y or -X * -Y => +Q
449 // +X * -Y or -X * +Y => -Q
450 Known.propagateXorSign(KnownLHS, KnownRHS);
451
452 // Inf * Y => Inf or NaN
453 if (KnownLHS.isKnownAlways(fcInf | fcNan) ||
454 KnownRHS.isKnownAlways(fcInf | fcNan))
455 Known.knownNot(fcNormal | fcSubnormal | fcZero);
456
457 // 0 * Y => 0 or NaN
458 if (KnownRHS.isKnownAlways(fcZero | fcNan) ||
459 KnownLHS.isKnownAlways(fcZero | fcNan))
460 Known.knownNot(fcNormal | fcSubnormal | fcInf);
461
462 if (!KnownLHS.isKnownNeverNaN() || !KnownRHS.isKnownNeverNaN())
463 return Known;
464
465 // 0 * +/-inf => NaN
466 if ((KnownRHS.isKnownNeverInfinity() ||
467 KnownLHS.isKnownNeverLogicalZero(Mode)) &&
468 (KnownLHS.isKnownNeverInfinity() ||
469 KnownRHS.isKnownNeverLogicalZero(Mode)))
470 Known.knownNot(fcNan);
471
472 return Known;
473}
474
475// TODO: This generalizes to known ranges
477 const APFloat &CRHS, DenormalMode Mode) {
478 // Match denormal scaling pattern, similar to the case in ldexp. If the
479 // constant's exponent is sufficiently large, the result cannot be subnormal.
480
481 const fltSemantics &Flt = CRHS.getSemantics();
482 unsigned Precision = APFloat::semanticsPrecision(Flt);
483 const int MantissaBits = Precision - 1;
484
485 int MinKnownExponent = ilogb(CRHS);
486 bool CannotBeSubnormal = (MinKnownExponent >= MantissaBits);
487
488 KnownFPClass Known = KnownFPClass::fmul(KnownLHS, KnownFPClass(CRHS), Mode);
489 if (CannotBeSubnormal)
490 Known.knownNot(fcSubnormal);
491
492 // Multiply of values <= 1 cannot introduce overflow.
493 if (KnownLHS.isKnownNever(fcInf)) {
494 if (MinKnownExponent < 0)
495 Known.knownNot(fcInf);
496 else if (MinKnownExponent == 0 && CRHS.compareAbsoluteValue(APFloat::getOne(
497 Flt)) == APFloat::cmpEqual)
498 Known.knownNot(fcInf);
499 }
500
501 return Known;
502}
503
505 const KnownFPClass &KnownRHS,
506 DenormalMode Mode) {
508
509 Known.propagateNonSNaN(KnownLHS, KnownRHS);
510
511 // Only 0/0, Inf/Inf produce NaN.
512 if (KnownLHS.isKnownNeverNaN() && KnownRHS.isKnownNeverNaN() &&
513 (KnownLHS.isKnownNeverInfinity() || KnownRHS.isKnownNeverInfinity()) &&
514 (KnownLHS.isKnownNeverLogicalZero(Mode) ||
515 KnownRHS.isKnownNeverLogicalZero(Mode))) {
516 Known.knownNot(fcNan);
517 }
518
519 // X / -0.0 => -Inf (or NaN)
520 // +X / +Y or -X / -Y => +Q
521 // +X / -Y or -X / +Y => -Q
522 Known.propagateXorSign(KnownLHS, KnownRHS);
523
524 // Normal and subnormal results require two non-zero finite operands.
525 if ((KnownLHS.isKnownNever(fcNegNormal | fcNegSubnormal) &&
529 Known.knownNot(fcNegNormal | fcNegSubnormal);
530 if ((KnownLHS.isKnownNever(fcNegNormal | fcNegSubnormal) &&
534 Known.knownNot(fcPosNormal | fcPosSubnormal);
535
536 // 0 / X => 0 or NaN
537 if (KnownLHS.isKnownAlways(fcZero))
538 Known.knownNot(fcSubnormal | fcNormal | fcInf);
539
540 // X / 0 => NaN or Inf
541 if (KnownRHS.isKnownAlways(fcZero))
542 Known.knownNot(fcFinite);
543
544 return Known;
545}
546
548 DenormalMode Mode) {
549 // X / X is always exactly 1.0 or a NaN.
551
552 Known.propagateNonSNaN(KnownSrc);
553
554 if (KnownSrc.isKnownNeverInfOrNaN() && KnownSrc.isKnownNeverLogicalZero(Mode))
555 Known.knownNot(fcNan);
556
557 return Known;
558}
559
561 const KnownFPClass &KnownRHS,
562 DenormalMode Mode) {
564
565 Known.knownNot(fcInf);
566
567 // Inf REM x and x REM 0 produce NaN.
568 if (KnownLHS.isKnownNeverNaN() && KnownRHS.isKnownNeverNaN() &&
569 KnownLHS.isKnownNeverInfinity() &&
570 KnownRHS.isKnownNeverLogicalZero(Mode)) {
571 Known.knownNot(fcNan);
572 }
573
574 // The sign for frem is the same as the first operand.
575 if (KnownLHS.cannotBeOrderedLessThanZero())
577 if (KnownLHS.cannotBeOrderedGreaterThanZero())
579
580 // See if we can be more aggressive about the sign of 0.
581 if (KnownLHS.isKnownNever(fcNegative))
582 Known.knownNot(fcNegative);
583 if (KnownLHS.isKnownNever(fcPositive))
584 Known.knownNot(fcPositive);
585
586 return Known;
587}
588
590 DenormalMode Mode) {
591 // X % X is always exactly [+-]0.0 or a NaN.
593
594 if (KnownSrc.isKnownNeverInfOrNaN() && KnownSrc.isKnownNeverLogicalZero(Mode))
595 Known.knownNot(fcNan);
596 else if (KnownSrc.isKnownNever(fcSNan))
597 Known.knownNot(fcSNan);
598
599 return Known;
600}
601
603 const KnownFPClass &KnownRHS,
604 const KnownFPClass &KnownAddend,
605 DenormalMode Mode) {
606 KnownFPClass Mul = fmul(KnownLHS, KnownRHS, Mode);
607
608 // FMA differs from the base fmul + fadd handling only in the treatment of -0
609 // results.
610 //
611 // If the multiply is a -0 due to rounding, the final -0 + 0 will be -0,
612 // unlike for a separate fadd.
613 KnownFPClass Known = fadd_impl(Mul, KnownAddend, Mode);
614
615 // propagateNonSNaN for 3 arguments.
616 if (KnownLHS.isKnownNever(fcSNan) && KnownRHS.isKnownNever(fcSNan) &&
617 KnownAddend.isKnownNever(fcSNan))
618 Known.knownNot(fcSNan);
619
620 return Known;
621}
622
624 const KnownFPClass &KnownAddend,
625 DenormalMode Mode) {
626 KnownFPClass Squared = square(KnownSquared, Mode);
627 KnownFPClass Known = fadd_impl(Squared, KnownAddend, Mode);
628
629 // Since we know the squared input must be positive, the add of opposite sign
630 // infinities nan hazard only applies for negative inf.
631 //
632 // TODO: Alternatively to proving addend is not -inf, we could know Squared is
633 // not pinf. Other than the degenerate always-subnormal input case, we can't
634 // prove that without a known range.
635 if (KnownAddend.isKnownNever(fcNegInf | fcNan) && Squared.isKnownNever(fcNan))
636 Known.knownNot(fcNan);
637
638 Known.propagateNonSNaN(KnownSquared, KnownAddend);
639
640 return Known;
641}
642
645 Known.knownNot(fcNegative);
646
647 Known.propagateNonNaN(KnownSrc);
648
649 if (KnownSrc.cannotBeOrderedLessThanZero()) {
650 // If the source is positive this cannot underflow.
651 Known.knownNot(fcPosZero);
652
653 // Cannot introduce denormal values.
654 Known.knownNot(fcPosSubnormal);
655 }
656
657 // If the source is negative, this cannot overflow to infinity.
658 if (KnownSrc.cannotBeOrderedGreaterThanZero())
659 Known.knownNot(fcPosInf);
660
661 return Known;
662}
663
669
671 DenormalMode Mode) {
673 Known.knownNot(fcNegZero | fcSubnormal);
674
675 Known.propagateNonSNaN(KnownSrc);
676
677 if (KnownSrc.isKnownNeverPosInfinity())
678 Known.knownNot(fcPosInf);
679
680 if (KnownSrc.isKnownNeverNaN() && KnownSrc.cannotBeOrderedLessThanZero())
681 Known.knownNot(fcNan);
682
683 if (KnownSrc.isKnownNeverLogicalZero(Mode))
684 Known.knownNot(fcNegInf);
685
686 return Known;
687}
688
690 DenormalMode Mode) {
692 Known.knownNot(fcPosSubnormal);
693
694 if (KnownSrc.isKnownNeverPosInfinity())
695 Known.knownNot(fcPosInf);
696
697 Known.propagateNonSNaN(KnownSrc);
698
699 // Any negative value besides -0 returns a nan.
700 if (KnownSrc.isKnownNeverNaN() && KnownSrc.cannotBeOrderedLessThanZero())
701 Known.knownNot(fcNan);
702
703 // The only negative value that can be returned is -0 for -0 inputs.
705
706 // If the input denormal mode could be PreserveSign, a negative
707 // subnormal input could produce a negative zero output.
708 if (KnownSrc.isKnownNeverLogicalNegZero(Mode))
709 Known.knownNot(fcNegZero);
710
711 return Known;
712}
713
716
717 Known.propagateNonSNaN(KnownSrc);
718
719 // Return NaN on infinite inputs.
720 Known.knownNot(fcInf);
721 if (KnownSrc.isKnownNeverNaN() && KnownSrc.isKnownNeverInfinity())
722 Known.knownNot(fcNan);
723
724 return Known;
725}
726
728 return sin(KnownSrc);
729}
730
733
734 // tan never returns Inf (tan(+-Inf) = NaN; tan(finite) = finite).
735 Known.knownNot(fcInf);
736
737 Known.propagateNonSNaN(KnownSrc);
738
739 // NaN propagates. tan(+-Inf) is NaN.
740 if (KnownSrc.isKnownNeverNaN() && KnownSrc.isKnownNeverInfinity())
741 Known.knownNot(fcNan);
742
743 return Known;
744}
745
748
749 // sinh is sign-preserving: sinh(x) < 0 iff x < 0.
750 if (KnownSrc.isKnownNever(fcNegative))
751 Known.knownNot(fcNegative);
752
753 Known.propagateNonNaN(KnownSrc);
754
755 return Known;
756}
757
760
761 // cosh(x) >= 1 for all real x; cosh(+-Inf) = +Inf. Never negative,
762 // zero, or subnormal.
763 Known.knownNot(fcNegative | fcZero | fcSubnormal);
764
765 Known.propagateNonNaN(KnownSrc);
766
767 return Known;
768}
769
772
773 // tanh is bounded to (-1, 1), never Inf.
774 Known.knownNot(fcInf);
775
776 // tanh is sign-preserving: tanh(x) < 0 iff x < 0.
777 if (KnownSrc.isKnownNever(fcNegative))
778 Known.knownNot(fcNegative);
779
780 Known.propagateNonNaN(KnownSrc);
781
782 return Known;
783}
784
787
788 // asin is bounded to [-pi/2, pi/2], never Inf.
789 Known.knownNot(fcInf);
790
791 Known.propagateNonSNaN(KnownSrc);
792
793 // asin is sign-preserving for finite arguments.
794 if (KnownSrc.isKnownNever(fcNegFinite))
795 Known.knownNot(fcNegFinite);
796
797 // NaN propagates. asin(x) is also NaN for |x| > 1, so we cannot rule
798 // out NaN without knowing the source is in [-1, 1].
799 return Known;
800}
801
804
805 // acos(x) is bounded to [0, pi] for -1 <= x <= 1, and is never negative,
806 // infinite, or subnormal. The smallest non-zero value occurs when x is
807 // close to 1.0, where acos(x) can be approximated by sqrt(2 * (1 - x)).
808 // Since sqrt cannot produce a subnormal result, we can conclude that
809 // acos(x) will also never produce a subnormal result.
810 Known.knownNot(fcNegative | fcInf | fcSubnormal);
811
812 // acos(x) == +0.0 iff x == +1.0
813 if (KnownSrc.isKnownNever(fcPosNormal))
814 Known.knownNot(fcZero);
815
816 Known.propagateNonSNaN(KnownSrc);
817
818 // NaN propagates. acos(x) is also NaN for |x| > 1, so we cannot rule
819 // out NaN without knowing the source is in [-1, 1].
820 return Known;
821}
822
825
826 // atan is bounded to (-pi/2, pi/2), never Inf. atan(+-Inf) = +-pi/2 (finite).
827 Known.knownNot(fcInf);
828
829 // atan is sign-preserving: atan(x) < 0 iff x < 0.
830 if (KnownSrc.isKnownNever(fcNegative))
831 Known.knownNot(fcNegative);
832
833 Known.propagateNonNaN(KnownSrc);
834
835 return Known;
836}
837
839 const KnownFPClass &KnownX,
840 DenormalMode Mode) {
842
843 // Even though these deductions are correct, we are ignoring the following
844 // potentially erroneous cases:
845 // * atan2(y, inf) is not subnormal
846 // * atan2(inf, x) is not zero or subnormal
847
848 // atan2 result is in (-pi, pi], never Inf.
849 Known.knownNot(fcInf);
850
851 Known.propagateNonNaN(KnownY, KnownX);
852
853 // Negative subnormals could be treated like positive zero.
854 const bool XCannotHavePositiveInput = KnownX.isKnownNever(fcPositive) &&
855 KnownX.isKnownNeverLogicalPosZero(Mode);
856 const bool YCannotHavePositiveInput = KnownY.isKnownNever(fcPositive) &&
857 KnownY.isKnownNeverLogicalPosZero(Mode);
858
859 // If x <= -0.0, then |atan2(y, x)| >= pi/2
860 if (XCannotHavePositiveInput)
861 Known.knownNot(fcZero | fcSubnormal);
862
863 // If y >= +0.0, then atan2(y, x) >= +0.0
864 if (KnownY.isKnownNever(fcNegative))
865 Known.knownNot(fcNegative);
866
867 // If y <= -0.0, then atan2(y, x) <= -0.0
868 // We do this deduction last in case we were able to rule out a negative
869 // subnormal result earlier.
870 if (YCannotHavePositiveInput) {
872 // Negative subnormal results can flush to +0.0.
873 if (Known.isKnownNever(fcNegSubnormal) || !Mode.outputsMayBePositiveZero())
874 Known.knownNot(fcPosZero);
875 }
876
877 return Known;
878}
879
881 const fltSemantics &DstTy,
882 const fltSemantics &SrcTy) {
883 // Infinity, nan and zero propagate from source.
884 KnownFPClass Known = KnownSrc;
885
886 // All subnormal inputs should be in the normal range in the result type.
887 if (APFloat::isRepresentableAsNormalIn(SrcTy, DstTy)) {
888 if (Known.getKnownFPClasses() & fcPosSubnormal)
889 Known.setKnownFPClasses(Known.getKnownFPClasses() | fcPosNormal);
890 if (Known.getKnownFPClasses() & fcNegSubnormal)
891 Known.setKnownFPClasses(Known.getKnownFPClasses() | fcNegNormal);
892 Known.knownNot(fcSubnormal);
893 }
894
895 // Sign bit of a nan isn't guaranteed.
896 if (!Known.isKnownNeverNaN())
897 Known.setSignBit(std::nullopt);
898
899 return Known;
900}
901
904
905 // Sign should be preserved
906 // TODO: Handle cannot be ordered greater than zero
907 if (KnownSrc.cannotBeOrderedLessThanZero())
909
910 Known.propagateNonNaN(KnownSrc);
911
912 // Infinity needs a range check.
913 return Known;
914}
915
917 bool IsTrunc,
918 bool IsMultiUnitFPType) {
920
921 // Integer results cannot be subnormal.
922 Known.knownNot(fcSubnormal);
923
924 Known.propagateNonNaN(KnownSrc);
925
926 // Pass through infinities, except PPC_FP128 is a special case for
927 // intrinsics other than trunc.
928 if (IsTrunc || !IsMultiUnitFPType) {
929 if (KnownSrc.isKnownNeverPosInfinity())
930 Known.knownNot(fcPosInf);
931 if (KnownSrc.isKnownNeverNegInfinity())
932 Known.knownNot(fcNegInf);
933 }
934
935 // Negative round ups to 0 produce -0
936 if (KnownSrc.isKnownNever(fcPosFinite))
937 Known.knownNot(fcPosFinite);
938 if (KnownSrc.isKnownNever(fcNegFinite))
939 Known.knownNot(fcNegFinite);
940
941 return Known;
942}
943
945 DenormalMode Mode) {
947 Known.knownNot(fcSubnormal);
948
949 if (KnownSrc.isKnownNever(fcNegative))
950 Known.knownNot(fcNegative);
951 else {
952 if (KnownSrc.isKnownNeverLogicalNegZero(Mode))
953 Known.knownNot(fcNegZero);
954 if (KnownSrc.isKnownNever(fcNegInf))
955 Known.knownNot(fcNegInf);
956 }
957
958 if (KnownSrc.isKnownNever(fcPositive))
959 Known.knownNot(fcPositive);
960 else {
961 if (KnownSrc.isKnownNeverLogicalPosZero(Mode))
962 Known.knownNot(fcPosZero);
963 if (KnownSrc.isKnownNever(fcPosInf))
964 Known.knownNot(fcPosInf);
965 }
966
967 Known.propagateNonNaN(KnownSrc);
968 return Known;
969}
970
972 const APInt &ConstantRangeExpMin,
973 const APInt &ConstantRangeExpMax,
974 const fltSemantics &Flt, DenormalMode Mode) {
976 Known.propagateNonNaN(KnownSrc);
977
978 // Sign is preserved, but underflows may produce zeroes.
979 if (KnownSrc.isKnownNever(fcNegative))
980 Known.knownNot(fcNegative);
981 else if (KnownSrc.cannotBeOrderedLessThanZero())
983
984 if (KnownSrc.isKnownNever(fcPositive))
985 Known.knownNot(fcPositive);
986 else if (KnownSrc.cannotBeOrderedGreaterThanZero())
988
989 unsigned Precision = APFloat::semanticsPrecision(Flt);
990 const int MantissaBits = Precision - 1;
991 if (ConstantRangeExpMin.sge(MantissaBits))
992 Known.knownNot(fcSubnormal);
993
994 if (ConstantRangeExpMin.isZero() && ConstantRangeExpMax.isZero()) {
995 // ldexp(x, 0) -> x, so propagate everything.
996 Known.propagateCanonicalizingSrc(KnownSrc, Mode);
997 } else if (ConstantRangeExpMax.isNonPositive()) {
998 // If we know the power is <= 0, can't introduce inf
999 if (KnownSrc.isKnownNeverPosInfinity())
1000 Known.knownNot(fcPosInf);
1001 if (KnownSrc.isKnownNeverNegInfinity())
1002 Known.knownNot(fcNegInf);
1003 } else if (ConstantRangeExpMin.isNonNegative()) {
1004 // If we know the power is >= 0, can't introduce subnormal or zero
1005 if (KnownSrc.isKnownNeverPosSubnormal())
1006 Known.knownNot(fcPosSubnormal);
1007 if (KnownSrc.isKnownNeverNegSubnormal())
1008 Known.knownNot(fcNegSubnormal);
1009 if (KnownSrc.isKnownNeverLogicalPosZero(Mode))
1010 Known.knownNot(fcPosZero);
1011 if (KnownSrc.isKnownNeverLogicalNegZero(Mode))
1012 Known.knownNot(fcNegZero);
1013 }
1014
1015 return Known;
1016}
1017
1019 const KnownBits &ExpBits,
1020 const fltSemantics &Flt, DenormalMode Mode) {
1021 return ldexp(KnownSrc, ExpBits.getSignedMinValue(),
1022 ExpBits.getSignedMaxValue(), Flt, Mode);
1023}
1024
1026 const KnownFPClass &KnownRHS) {
1028
1029 Known.propagateNonSNaN(KnownLHS, KnownRHS);
1030
1031 // pow may return NaN if one of the arguments is NaN. NaN may be produced from
1032 // a non-zero-finite-negative base and a non-integer exponent.
1033 if (KnownLHS.isKnownNever(fcNan | fcNegNormal | fcNegSubnormal) &&
1034 KnownRHS.isKnownNeverNaN())
1035 Known.knownNot(fcNan);
1036
1037 // We could rule out negative and subnormal results when exponent is known to
1038 // never be a normal value, but having either argument being known to never be
1039 // normal is unlikely and not worth considering.
1040
1041 // Only a negative base raised to an odd power returns a negative value.
1042 if (KnownLHS.isKnownNever(fcNegative)) {
1043 Known.knownNot(fcNegative);
1044 } else if (KnownLHS.isKnownNever(fcNegNormal | fcNegSubnormal)) {
1045 Known.knownNot(fcNegNormal | fcNegSubnormal);
1046 // See if we can also rule out -0.0 or -inf.
1047 // Here at least one of -0.0 or -inf is a possible base.
1048
1049 // pow(-0.0, odd-positive) = -0.0
1050 // pow(-inf, odd-negative) = -0.0
1051 if ((KnownLHS.isKnownNever(fcNegZero) ||
1052 KnownRHS.isKnownNever(fcPosNormal)) &&
1053 (KnownLHS.isKnownNever(fcNegInf) || KnownRHS.isKnownNever(fcNegNormal)))
1054 Known.knownNot(fcNegZero);
1055
1056 // pow(-0.0, odd-negative) = -inf
1057 // pow(-inf, odd-positive) = -inf
1058 if ((KnownLHS.isKnownNever(fcNegZero) ||
1059 KnownRHS.isKnownNever(fcNegNormal)) &&
1060 (KnownLHS.isKnownNever(fcNegInf) || KnownRHS.isKnownNever(fcPosNormal)))
1061 Known.knownNot(fcNegInf);
1062 }
1063
1064 return Known;
1065}
1066
1068 const KnownBits &ExponentKnownBits) {
1070 Known.propagateNonNaN(KnownSrc);
1071
1072 if (ExponentKnownBits.isZero()) {
1073 // powi(QNaN, 0) returns 1.0, and powi(SNaN, 0) may non-deterministically
1074 // return 1.0 or a NaN.
1075 if (KnownSrc.isKnownNever(fcSNan)) {
1076 Known.knownNot(~fcPosNormal);
1077 return Known;
1078 }
1079
1080 Known.knownNot(~(fcPosNormal | fcNan));
1081 return Known;
1082 }
1083
1084 // Given that exp is an integer, here are the
1085 // ways that powi can return a negative value:
1086 //
1087 // powi(x, exp) --> negative if exp is odd and x is negative.
1088 // powi(-0, exp) --> -inf if exp is negative odd.
1089 // powi(-0, exp) --> -0 if exp is positive odd.
1090 // powi(-inf, exp) --> -0 if exp is negative odd.
1091 // powi(-inf, exp) --> -inf if exp is positive odd.
1092 if (KnownSrc.isKnownNever(fcNegative) || ExponentKnownBits.isEven()) {
1093 Known.knownNot(fcNegative);
1094 } else if (KnownSrc.isKnownNever(fcNegNormal | fcNegSubnormal)) {
1095 Known.knownNot(fcNegNormal | fcNegSubnormal);
1096 // See if we can also rule out -0.0 or -inf.
1097 // Here at least one of -0.0 or -inf is a possible base.
1098
1099 // We already know that ExponentKnownBits.isEven() is false here.
1100 const bool IsKnownNeverOddPositive = ExponentKnownBits.isNegative();
1101 const bool IsKnownNeverOddNegative = ExponentKnownBits.isNonNegative();
1102
1103 // powi(-0.0, odd-positive) = -0.0
1104 // powi(-inf, odd-negative) = -0.0
1105 if ((KnownSrc.isKnownNever(fcNegZero) || IsKnownNeverOddPositive) &&
1106 (KnownSrc.isKnownNever(fcNegInf) || IsKnownNeverOddNegative))
1107 Known.knownNot(fcNegZero);
1108
1109 // powi(-0.0, odd-negative) = -inf
1110 // powi(-inf, odd-positive) = -inf
1111 if ((KnownSrc.isKnownNever(fcNegZero) || IsKnownNeverOddNegative) &&
1112 (KnownSrc.isKnownNever(fcNegInf) || IsKnownNeverOddPositive))
1113 Known.knownNot(fcNegInf);
1114 }
1115
1116 // powi(x, exp) --> inf
1117 // when:
1118 // * powi(inf, exp), exp > 0
1119 // * powi(+/-0, exp), exp < 0
1120 // * powi(finite, exp), |exp| > 1
1121 // * powi(subnormal, -1)
1122 // TODO:
1123 // 1. This simple all or nothing approach. We can do better
1124 // and cover sign/parity and exp > 1 vs exp < -1 separately.
1125 // 2. powi(0/nan, exp), exp > 0 can be refinable
1126 // to fcNan | fcZero | fcPosNormal.
1127 {
1128 APInt MinExp = ExponentKnownBits.getSignedMinValue();
1129 APInt MaxExp = ExponentKnownBits.getSignedMaxValue();
1130
1131 // powi(inf, exp), exp > 0
1132 bool MayInfSrc =
1133 !KnownSrc.isKnownNever(fcInf) && MaxExp.isStrictlyPositive();
1134
1135 // powi(+/-0, exp), exp < 0
1136 bool MayDivByZero = !KnownSrc.isKnownNever(fcZero) && MinExp.isNegative();
1137
1138 // powi(finite, exp), |exp| > 1
1139 bool MayFinite = !KnownSrc.isKnownNever(fcNormal | fcSubnormal);
1140 bool MayAbsExpGT1 = MinExp.slt(-1) || MaxExp.sgt(1);
1141 bool MayFiniteOverflow = MayFinite && MayAbsExpGT1;
1142
1143 // powi(subnormal, -1)
1144 bool MayBeNegOne = ExponentKnownBits.Zero.isZero();
1145 bool MaySubnormInv = !KnownSrc.isKnownNever(fcSubnormal) && MayBeNegOne;
1146
1147 if (!MayInfSrc && !MayDivByZero && !MayFiniteOverflow && !MaySubnormInv)
1148 Known.knownNot(fcInf);
1149 }
1150
1151 return Known;
1152}
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:540
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:329
static LLVM_ABI Semantics SemanticsToEnum(const llvm::fltSemantics &Sem)
Definition APFloat.cpp:185
static LLVM_ABI bool isRepresentableAsNormalIn(const fltSemantics &Src, const fltSemantics &Dst)
Definition APFloat.cpp:379
static LLVM_ABI bool isIEEELikeFP(const fltSemantics &)
Definition APFloat.cpp:370
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:1205
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
Definition APInt.h:254
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
Definition APInt.h:376
bool isNegative() const
Determine sign of this APInt.
Definition APInt.h:325
bool isNonPositive() const
Determine if this APInt Value is non-positive (<= 0).
Definition APInt.h:357
bool isStrictlyPositive() const
Determine if this APInt Value is positive.
Definition APInt.h:352
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
Definition APInt.h:330
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
Definition APInt.h:302
bool slt(const APInt &RHS) const
Signed less than comparison.
Definition APInt.h:1134
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
Definition APInt.h:196
bool sge(const APInt &RHS) const
Signed greater or equal comparison.
Definition APInt.h:1241
#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.
void setKnownFPClasses(FPClassTest Classes)
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
FPClassTest KnownFPClassesValue
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.
FPClassTest getKnownFPClasses() const
Floating-point classes the value could be one of.
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