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 return Known;
415}
416
418 DenormalMode Mode) {
419 KnownFPClass Known = fadd(KnownSrc, KnownSrc, Mode);
420
421 // Doubling 0 will give the same 0.
422 if (KnownSrc.isKnownNeverLogicalPosZero(Mode) &&
423 (Mode.Output == DenormalMode::IEEE ||
424 (Mode.Output == DenormalMode::PreserveSign &&
425 KnownSrc.isKnownNeverPosSubnormal()) ||
426 (Mode.Output == DenormalMode::PositiveZero &&
427 KnownSrc.isKnownNeverSubnormal())))
428 Known.knownNot(fcPosZero);
429
430 return Known;
431}
432
434 const KnownFPClass &KnownRHS,
435 DenormalMode Mode) {
436 return fadd(KnownLHS, fneg(KnownRHS), Mode);
437}
438
440 const KnownFPClass &KnownRHS,
441 DenormalMode Mode) {
443
444 // +X * +Y or -X * -Y => +Q
445 // +X * -Y or -X * +Y => -Q
446 Known.propagateXorSign(KnownLHS, KnownRHS);
447
448 // Inf * Y => Inf or NaN
449 if (KnownLHS.isKnownAlways(fcInf | fcNan) ||
450 KnownRHS.isKnownAlways(fcInf | fcNan))
451 Known.knownNot(fcNormal | fcSubnormal | fcZero);
452
453 // 0 * Y => 0 or NaN
454 if (KnownRHS.isKnownAlways(fcZero | fcNan) ||
455 KnownLHS.isKnownAlways(fcZero | fcNan))
456 Known.knownNot(fcNormal | fcSubnormal | fcInf);
457
458 if (!KnownLHS.isKnownNeverNaN() || !KnownRHS.isKnownNeverNaN())
459 return Known;
460
461 // 0 * +/-inf => NaN
462 if ((KnownRHS.isKnownNeverInfinity() ||
463 KnownLHS.isKnownNeverLogicalZero(Mode)) &&
464 (KnownLHS.isKnownNeverInfinity() ||
465 KnownRHS.isKnownNeverLogicalZero(Mode)))
466 Known.knownNot(fcNan);
467
468 return Known;
469}
470
471// TODO: This generalizes to known ranges
473 const APFloat &CRHS, DenormalMode Mode) {
474 // Match denormal scaling pattern, similar to the case in ldexp. If the
475 // constant's exponent is sufficiently large, the result cannot be subnormal.
476
477 const fltSemantics &Flt = CRHS.getSemantics();
478 unsigned Precision = APFloat::semanticsPrecision(Flt);
479 const int MantissaBits = Precision - 1;
480
481 int MinKnownExponent = ilogb(CRHS);
482 bool CannotBeSubnormal = (MinKnownExponent >= MantissaBits);
483
484 KnownFPClass Known = KnownFPClass::fmul(KnownLHS, KnownFPClass(CRHS), Mode);
485 if (CannotBeSubnormal)
486 Known.knownNot(fcSubnormal);
487
488 // Multiply of values <= 1 cannot introduce overflow.
489 if (KnownLHS.isKnownNever(fcInf)) {
490 if (MinKnownExponent < 0)
491 Known.knownNot(fcInf);
492 else if (MinKnownExponent == 0 && CRHS.compareAbsoluteValue(APFloat::getOne(
493 Flt)) == APFloat::cmpEqual)
494 Known.knownNot(fcInf);
495 }
496
497 return Known;
498}
499
501 const KnownFPClass &KnownRHS,
502 DenormalMode Mode) {
504
505 // Only 0/0, Inf/Inf produce NaN.
506 if (KnownLHS.isKnownNeverNaN() && KnownRHS.isKnownNeverNaN() &&
507 (KnownLHS.isKnownNeverInfinity() || KnownRHS.isKnownNeverInfinity()) &&
508 (KnownLHS.isKnownNeverLogicalZero(Mode) ||
509 KnownRHS.isKnownNeverLogicalZero(Mode))) {
510 Known.knownNot(fcNan);
511 }
512
513 // X / -0.0 => -Inf (or NaN)
514 // +X / +Y or -X / -Y => +Q
515 // +X / -Y or -X / +Y => -Q
516 Known.propagateXorSign(KnownLHS, KnownRHS);
517
518 // Normal and subnormal results require two non-zero finite operands.
519 if ((KnownLHS.isKnownNever(fcNegNormal | fcNegSubnormal) &&
523 Known.knownNot(fcNegNormal | fcNegSubnormal);
524 if ((KnownLHS.isKnownNever(fcNegNormal | fcNegSubnormal) &&
528 Known.knownNot(fcPosNormal | fcPosSubnormal);
529
530 // 0 / X => 0 or NaN
531 if (KnownLHS.isKnownAlways(fcZero))
532 Known.knownNot(fcSubnormal | fcNormal | fcInf);
533
534 // X / 0 => NaN or Inf
535 if (KnownRHS.isKnownAlways(fcZero))
536 Known.knownNot(fcFinite);
537
538 return Known;
539}
540
542 DenormalMode Mode) {
543 // X / X is always exactly 1.0 or a NaN.
545
546 if (KnownSrc.isKnownNeverInfOrNaN() && KnownSrc.isKnownNeverLogicalZero(Mode))
547 Known.knownNot(fcNan);
548 else if (KnownSrc.isKnownNever(fcSNan))
549 Known.knownNot(fcSNan);
550
551 return Known;
552}
553
555 const KnownFPClass &KnownRHS,
556 DenormalMode Mode) {
558
559 Known.knownNot(fcInf);
560
561 // Inf REM x and x REM 0 produce NaN.
562 if (KnownLHS.isKnownNeverNaN() && KnownRHS.isKnownNeverNaN() &&
563 KnownLHS.isKnownNeverInfinity() &&
564 KnownRHS.isKnownNeverLogicalZero(Mode)) {
565 Known.knownNot(fcNan);
566 }
567
568 // The sign for frem is the same as the first operand.
569 if (KnownLHS.cannotBeOrderedLessThanZero())
571 if (KnownLHS.cannotBeOrderedGreaterThanZero())
573
574 // See if we can be more aggressive about the sign of 0.
575 if (KnownLHS.isKnownNever(fcNegative))
576 Known.knownNot(fcNegative);
577 if (KnownLHS.isKnownNever(fcPositive))
578 Known.knownNot(fcPositive);
579
580 return Known;
581}
582
584 DenormalMode Mode) {
585 // X % X is always exactly [+-]0.0 or a NaN.
587
588 if (KnownSrc.isKnownNeverInfOrNaN() && KnownSrc.isKnownNeverLogicalZero(Mode))
589 Known.knownNot(fcNan);
590 else if (KnownSrc.isKnownNever(fcSNan))
591 Known.knownNot(fcSNan);
592
593 return Known;
594}
595
597 const KnownFPClass &KnownRHS,
598 const KnownFPClass &KnownAddend,
599 DenormalMode Mode) {
600 KnownFPClass Mul = fmul(KnownLHS, KnownRHS, Mode);
601
602 // FMA differs from the base fmul + fadd handling only in the treatment of -0
603 // results.
604 //
605 // If the multiply is a -0 due to rounding, the final -0 + 0 will be -0,
606 // unlike for a separate fadd.
607 return fadd_impl(Mul, KnownAddend, Mode);
608}
609
611 const KnownFPClass &KnownAddend,
612 DenormalMode Mode) {
613 KnownFPClass Squared = square(KnownSquared, Mode);
614 KnownFPClass Known = fadd_impl(Squared, KnownAddend, Mode);
615
616 // Since we know the squared input must be positive, the add of opposite sign
617 // infinities nan hazard only applies for negative inf.
618 //
619 // TODO: Alternatively to proving addend is not -inf, we could know Squared is
620 // not pinf. Other than the degenerate always-subnormal input case, we can't
621 // prove that without a known range.
622 if (KnownAddend.isKnownNever(fcNegInf | fcNan) && Squared.isKnownNever(fcNan))
623 Known.knownNot(fcNan);
624
625 return Known;
626}
627
630 Known.knownNot(fcNegative);
631
632 Known.propagateNonNaN(KnownSrc);
633
634 if (KnownSrc.cannotBeOrderedLessThanZero()) {
635 // If the source is positive this cannot underflow.
636 Known.knownNot(fcPosZero);
637
638 // Cannot introduce denormal values.
639 Known.knownNot(fcPosSubnormal);
640 }
641
642 // If the source is negative, this cannot overflow to infinity.
643 if (KnownSrc.cannotBeOrderedGreaterThanZero())
644 Known.knownNot(fcPosInf);
645
646 return Known;
647}
648
654
656 DenormalMode Mode) {
658 Known.knownNot(fcNegZero | fcSubnormal);
659
660 Known.propagateNonSNaN(KnownSrc);
661
662 if (KnownSrc.isKnownNeverPosInfinity())
663 Known.knownNot(fcPosInf);
664
665 if (KnownSrc.isKnownNeverNaN() && KnownSrc.cannotBeOrderedLessThanZero())
666 Known.knownNot(fcNan);
667
668 if (KnownSrc.isKnownNeverLogicalZero(Mode))
669 Known.knownNot(fcNegInf);
670
671 return Known;
672}
673
675 DenormalMode Mode) {
677 Known.knownNot(fcPosSubnormal);
678
679 if (KnownSrc.isKnownNeverPosInfinity())
680 Known.knownNot(fcPosInf);
681
682 Known.propagateNonSNaN(KnownSrc);
683
684 // Any negative value besides -0 returns a nan.
685 if (KnownSrc.isKnownNeverNaN() && KnownSrc.cannotBeOrderedLessThanZero())
686 Known.knownNot(fcNan);
687
688 // The only negative value that can be returned is -0 for -0 inputs.
690
691 // If the input denormal mode could be PreserveSign, a negative
692 // subnormal input could produce a negative zero output.
693 if (KnownSrc.isKnownNeverLogicalNegZero(Mode))
694 Known.knownNot(fcNegZero);
695
696 return Known;
697}
698
701
702 // Return NaN on infinite inputs.
703 Known.knownNot(fcInf);
704 if (KnownSrc.isKnownNeverNaN() && KnownSrc.isKnownNeverInfinity())
705 Known.knownNot(fcNan);
706
707 return Known;
708}
709
711 return sin(KnownSrc);
712}
713
716
717 // tan never returns Inf (tan(+-Inf) = NaN; tan(finite) = finite).
718 Known.knownNot(fcInf);
719
720 // NaN propagates. tan(+-Inf) is NaN.
721 if (KnownSrc.isKnownNeverNaN() && KnownSrc.isKnownNeverInfinity())
722 Known.knownNot(fcNan);
723
724 return Known;
725}
726
729
730 // sinh is sign-preserving: sinh(x) < 0 iff x < 0.
731 if (KnownSrc.isKnownNever(fcNegative))
732 Known.knownNot(fcNegative);
733
734 Known.propagateNonNaN(KnownSrc);
735
736 return Known;
737}
738
741
742 // cosh(x) >= 1 for all real x; cosh(+-Inf) = +Inf. Never negative,
743 // zero, or subnormal.
744 Known.knownNot(fcNegative | fcZero | fcSubnormal);
745
746 Known.propagateNonNaN(KnownSrc);
747
748 return Known;
749}
750
753
754 // tanh is bounded to (-1, 1), never Inf.
755 Known.knownNot(fcInf);
756
757 // tanh is sign-preserving: tanh(x) < 0 iff x < 0.
758 if (KnownSrc.isKnownNever(fcNegative))
759 Known.knownNot(fcNegative);
760
761 Known.propagateNonNaN(KnownSrc);
762
763 return Known;
764}
765
768
769 // asin is bounded to [-pi/2, pi/2], never Inf.
770 Known.knownNot(fcInf);
771
772 Known.propagateNonSNaN(KnownSrc);
773
774 // asin is sign-preserving for finite arguments.
775 if (KnownSrc.isKnownNever(fcNegFinite))
776 Known.knownNot(fcNegFinite);
777
778 // NaN propagates. asin(x) is also NaN for |x| > 1, so we cannot rule
779 // out NaN without knowing the source is in [-1, 1].
780 return Known;
781}
782
785
786 // acos(x) is bounded to [0, pi] for -1 <= x <= 1, and is never negative,
787 // infinite, or subnormal. The smallest non-zero value occurs when x is
788 // close to 1.0, where acos(x) can be approximated by sqrt(2 * (1 - x)).
789 // Since sqrt cannot produce a subnormal result, we can conclude that
790 // acos(x) will also never produce a subnormal result.
791 Known.knownNot(fcNegative | fcInf | fcSubnormal);
792
793 // acos(x) == +0.0 iff x == +1.0
794 if (KnownSrc.isKnownNever(fcPosNormal))
795 Known.knownNot(fcZero);
796
797 Known.propagateNonSNaN(KnownSrc);
798
799 // NaN propagates. acos(x) is also NaN for |x| > 1, so we cannot rule
800 // out NaN without knowing the source is in [-1, 1].
801 return Known;
802}
803
806
807 // atan is bounded to (-pi/2, pi/2), never Inf. atan(+-Inf) = +-pi/2 (finite).
808 Known.knownNot(fcInf);
809
810 // atan is sign-preserving: atan(x) < 0 iff x < 0.
811 if (KnownSrc.isKnownNever(fcNegative))
812 Known.knownNot(fcNegative);
813
814 Known.propagateNonNaN(KnownSrc);
815
816 return Known;
817}
818
820 const KnownFPClass &KnownX,
821 DenormalMode Mode) {
823
824 // Even though these deductions are correct, we are ignoring the following
825 // potentially erroneous cases:
826 // * atan2(y, inf) is not subnormal
827 // * atan2(inf, x) is not zero or subnormal
828
829 // atan2 result is in (-pi, pi], never Inf.
830 Known.knownNot(fcInf);
831
832 Known.propagateNonNaN(KnownY, KnownX);
833
834 // Negative subnormals could be treated like positive zero.
835 const bool XCannotHavePositiveValue = KnownX.isKnownNever(fcPositive) &&
836 KnownX.isKnownNeverLogicalPosZero(Mode);
837
838 // If x <= -0.0, then |atan2(y, x)| >= pi/2
839 if (XCannotHavePositiveValue)
840 Known.knownNot(fcZero | fcSubnormal);
841
842 return Known;
843}
844
846 const fltSemantics &DstTy,
847 const fltSemantics &SrcTy) {
848 // Infinity, nan and zero propagate from source.
849 KnownFPClass Known = KnownSrc;
850
851 // All subnormal inputs should be in the normal range in the result type.
852 if (APFloat::isRepresentableAsNormalIn(SrcTy, DstTy)) {
853 if (Known.getKnownFPClasses() & fcPosSubnormal)
854 Known.setKnownFPClasses(Known.getKnownFPClasses() | fcPosNormal);
855 if (Known.getKnownFPClasses() & fcNegSubnormal)
856 Known.setKnownFPClasses(Known.getKnownFPClasses() | fcNegNormal);
857 Known.knownNot(fcSubnormal);
858 }
859
860 // Sign bit of a nan isn't guaranteed.
861 if (!Known.isKnownNeverNaN())
862 Known.setSignBit(std::nullopt);
863
864 return Known;
865}
866
869
870 // Sign should be preserved
871 // TODO: Handle cannot be ordered greater than zero
872 if (KnownSrc.cannotBeOrderedLessThanZero())
874
875 Known.propagateNonNaN(KnownSrc);
876
877 // Infinity needs a range check.
878 return Known;
879}
880
882 bool IsTrunc,
883 bool IsMultiUnitFPType) {
885
886 // Integer results cannot be subnormal.
887 Known.knownNot(fcSubnormal);
888
889 Known.propagateNonNaN(KnownSrc);
890
891 // Pass through infinities, except PPC_FP128 is a special case for
892 // intrinsics other than trunc.
893 if (IsTrunc || !IsMultiUnitFPType) {
894 if (KnownSrc.isKnownNeverPosInfinity())
895 Known.knownNot(fcPosInf);
896 if (KnownSrc.isKnownNeverNegInfinity())
897 Known.knownNot(fcNegInf);
898 }
899
900 // Negative round ups to 0 produce -0
901 if (KnownSrc.isKnownNever(fcPosFinite))
902 Known.knownNot(fcPosFinite);
903 if (KnownSrc.isKnownNever(fcNegFinite))
904 Known.knownNot(fcNegFinite);
905
906 return Known;
907}
908
910 DenormalMode Mode) {
912 Known.knownNot(fcSubnormal);
913
914 if (KnownSrc.isKnownNever(fcNegative))
915 Known.knownNot(fcNegative);
916 else {
917 if (KnownSrc.isKnownNeverLogicalNegZero(Mode))
918 Known.knownNot(fcNegZero);
919 if (KnownSrc.isKnownNever(fcNegInf))
920 Known.knownNot(fcNegInf);
921 }
922
923 if (KnownSrc.isKnownNever(fcPositive))
924 Known.knownNot(fcPositive);
925 else {
926 if (KnownSrc.isKnownNeverLogicalPosZero(Mode))
927 Known.knownNot(fcPosZero);
928 if (KnownSrc.isKnownNever(fcPosInf))
929 Known.knownNot(fcPosInf);
930 }
931
932 Known.propagateNonNaN(KnownSrc);
933 return Known;
934}
935
937 const APInt &ConstantRangeExpMin,
938 const APInt &ConstantRangeExpMax,
939 const fltSemantics &Flt, DenormalMode Mode) {
941 Known.propagateNonNaN(KnownSrc);
942
943 // Sign is preserved, but underflows may produce zeroes.
944 if (KnownSrc.isKnownNever(fcNegative))
945 Known.knownNot(fcNegative);
946 else if (KnownSrc.cannotBeOrderedLessThanZero())
948
949 if (KnownSrc.isKnownNever(fcPositive))
950 Known.knownNot(fcPositive);
951 else if (KnownSrc.cannotBeOrderedGreaterThanZero())
953
954 unsigned Precision = APFloat::semanticsPrecision(Flt);
955 const int MantissaBits = Precision - 1;
956 if (ConstantRangeExpMin.sge(MantissaBits))
957 Known.knownNot(fcSubnormal);
958
959 if (ConstantRangeExpMin.isZero() && ConstantRangeExpMax.isZero()) {
960 // ldexp(x, 0) -> x, so propagate everything.
961 Known.propagateCanonicalizingSrc(KnownSrc, Mode);
962 } else if (ConstantRangeExpMax.isNonPositive()) {
963 // If we know the power is <= 0, can't introduce inf
964 if (KnownSrc.isKnownNeverPosInfinity())
965 Known.knownNot(fcPosInf);
966 if (KnownSrc.isKnownNeverNegInfinity())
967 Known.knownNot(fcNegInf);
968 } else if (ConstantRangeExpMin.isNonNegative()) {
969 // If we know the power is >= 0, can't introduce subnormal or zero
970 if (KnownSrc.isKnownNeverPosSubnormal())
971 Known.knownNot(fcPosSubnormal);
972 if (KnownSrc.isKnownNeverNegSubnormal())
973 Known.knownNot(fcNegSubnormal);
974 if (KnownSrc.isKnownNeverLogicalPosZero(Mode))
975 Known.knownNot(fcPosZero);
976 if (KnownSrc.isKnownNeverLogicalNegZero(Mode))
977 Known.knownNot(fcNegZero);
978 }
979
980 return Known;
981}
982
984 const KnownBits &ExpBits,
985 const fltSemantics &Flt, DenormalMode Mode) {
986 return ldexp(KnownSrc, ExpBits.getSignedMinValue(),
987 ExpBits.getSignedMaxValue(), Flt, Mode);
988}
989
991 const KnownFPClass &KnownRHS) {
993
994 Known.propagateNonSNaN(KnownLHS, KnownRHS);
995
996 // pow may return NaN if one of the arguments is NaN. NaN may be produced from
997 // a non-zero-finite-negative base and a non-integer exponent.
998 if (KnownLHS.isKnownNever(fcNan | fcNegNormal | fcNegSubnormal) &&
999 KnownRHS.isKnownNeverNaN())
1000 Known.knownNot(fcNan);
1001
1002 // We could rule out negative and subnormal results when exponent is known to
1003 // never be a normal value, but having either argument being known to never be
1004 // normal is unlikely and not worth considering.
1005
1006 // Only a negative base raised to an odd power returns a negative value.
1007 if (KnownLHS.isKnownNever(fcNegative)) {
1008 Known.knownNot(fcNegative);
1009 } else if (KnownLHS.isKnownNever(fcNegNormal | fcNegSubnormal)) {
1010 Known.knownNot(fcNegNormal | fcNegSubnormal);
1011 // See if we can also rule out -0.0 or -inf.
1012 // Here at least one of -0.0 or -inf is a possible base.
1013
1014 // pow(-0.0, odd-positive) = -0.0
1015 // pow(-inf, odd-negative) = -0.0
1016 if ((KnownLHS.isKnownNever(fcNegZero) ||
1017 KnownRHS.isKnownNever(fcPosNormal)) &&
1018 (KnownLHS.isKnownNever(fcNegInf) || KnownRHS.isKnownNever(fcNegNormal)))
1019 Known.knownNot(fcNegZero);
1020
1021 // pow(-0.0, odd-negative) = -inf
1022 // pow(-inf, odd-positive) = -inf
1023 if ((KnownLHS.isKnownNever(fcNegZero) ||
1024 KnownRHS.isKnownNever(fcNegNormal)) &&
1025 (KnownLHS.isKnownNever(fcNegInf) || KnownRHS.isKnownNever(fcPosNormal)))
1026 Known.knownNot(fcNegInf);
1027 }
1028
1029 return Known;
1030}
1031
1033 const KnownBits &ExponentKnownBits) {
1035 Known.propagateNonNaN(KnownSrc);
1036
1037 if (ExponentKnownBits.isZero()) {
1038 // powi(QNaN, 0) returns 1.0, and powi(SNaN, 0) may non-deterministically
1039 // return 1.0 or a NaN.
1040 if (KnownSrc.isKnownNever(fcSNan)) {
1041 Known.knownNot(~fcPosNormal);
1042 return Known;
1043 }
1044
1045 Known.knownNot(~(fcPosNormal | fcNan));
1046 return Known;
1047 }
1048
1049 // Given that exp is an integer, here are the
1050 // ways that powi can return a negative value:
1051 //
1052 // powi(x, exp) --> negative if exp is odd and x is negative.
1053 // powi(-0, exp) --> -inf if exp is negative odd.
1054 // powi(-0, exp) --> -0 if exp is positive odd.
1055 // powi(-inf, exp) --> -0 if exp is negative odd.
1056 // powi(-inf, exp) --> -inf if exp is positive odd.
1057 if (KnownSrc.isKnownNever(fcNegative) || ExponentKnownBits.isEven()) {
1058 Known.knownNot(fcNegative);
1059 } else if (KnownSrc.isKnownNever(fcNegNormal | fcNegSubnormal)) {
1060 Known.knownNot(fcNegNormal | fcNegSubnormal);
1061 // See if we can also rule out -0.0 or -inf.
1062 // Here at least one of -0.0 or -inf is a possible base.
1063
1064 // We already know that ExponentKnownBits.isEven() is false here.
1065 const bool IsKnownNeverOddPositive = ExponentKnownBits.isNegative();
1066 const bool IsKnownNeverOddNegative = ExponentKnownBits.isNonNegative();
1067
1068 // powi(-0.0, odd-positive) = -0.0
1069 // powi(-inf, odd-negative) = -0.0
1070 if ((KnownSrc.isKnownNever(fcNegZero) || IsKnownNeverOddPositive) &&
1071 (KnownSrc.isKnownNever(fcNegInf) || IsKnownNeverOddNegative))
1072 Known.knownNot(fcNegZero);
1073
1074 // powi(-0.0, odd-negative) = -inf
1075 // powi(-inf, odd-positive) = -inf
1076 if ((KnownSrc.isKnownNever(fcNegZero) || IsKnownNeverOddNegative) &&
1077 (KnownSrc.isKnownNever(fcNegInf) || IsKnownNeverOddPositive))
1078 Known.knownNot(fcNegInf);
1079 }
1080
1081 // powi(x, exp) --> inf
1082 // when:
1083 // * powi(inf, exp), exp > 0
1084 // * powi(+/-0, exp), exp < 0
1085 // * powi(finite, exp), |exp| > 1
1086 // * powi(subnormal, -1)
1087 // TODO:
1088 // 1. This simple all or nothing approach. We can do better
1089 // and cover sign/parity and exp > 1 vs exp < -1 separately.
1090 // 2. powi(0/nan, exp), exp > 0 can be refinable
1091 // to fcNan | fcZero | fcPosNormal.
1092 {
1093 APInt MinExp = ExponentKnownBits.getSignedMinValue();
1094 APInt MaxExp = ExponentKnownBits.getSignedMaxValue();
1095
1096 // powi(inf, exp), exp > 0
1097 bool MayInfSrc =
1098 !KnownSrc.isKnownNever(fcInf) && MaxExp.isStrictlyPositive();
1099
1100 // powi(+/-0, exp), exp < 0
1101 bool MayDivByZero = !KnownSrc.isKnownNever(fcZero) && MinExp.isNegative();
1102
1103 // powi(finite, exp), |exp| > 1
1104 bool MayFinite = !KnownSrc.isKnownNever(fcNormal | fcSubnormal);
1105 bool MayAbsExpGT1 = MinExp.slt(-1) || MaxExp.sgt(1);
1106 bool MayFiniteOverflow = MayFinite && MayAbsExpGT1;
1107
1108 // powi(subnormal, -1)
1109 bool MayBeNegOne = ExponentKnownBits.Zero.isZero();
1110 bool MaySubnormInv = !KnownSrc.isKnownNever(fcSubnormal) && MayBeNegOne;
1111
1112 if (!MayInfSrc && !MayDivByZero && !MayFiniteOverflow && !MaySubnormInv)
1113 Known.knownNot(fcInf);
1114 }
1115
1116 return Known;
1117}
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:318
static LLVM_ABI Semantics SemanticsToEnum(const llvm::fltSemantics &Sem)
Definition APFloat.cpp:183
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.
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