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