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 // Transfer information from the sign bit.
245 if (Bits.isNonNegative())
246 Known.signBitMustBeZero();
247 else if (Bits.isNegative())
248 Known.signBitMustBeOne();
249
250 if (APFloat::isIEEELikeFP(FltSemantics)) {
251 const unsigned MantissaBits = FltSemantics.precision - 1;
252 const APInt ExponentMask = APInt::getBitsSet(
253 FltSemantics.sizeInBits, MantissaBits, FltSemantics.sizeInBits - 1);
254 const APInt MantissaMask =
255 APInt::getLowBitsSet(FltSemantics.sizeInBits, MantissaBits);
256
257 const bool ExponentKnownAllZeros =
258 (Bits.Zero & ExponentMask) == ExponentMask;
259 const bool ExponentKnownAllOnes = (Bits.One & ExponentMask) == ExponentMask;
260 const bool ExponentKnownNotAllZeros = !(Bits.One & ExponentMask).isZero();
261 const bool ExponentKnownNotAllOnes = !(Bits.Zero & ExponentMask).isZero();
262
263 const bool MantissaKnownAllZeros =
264 (Bits.Zero & MantissaMask) == MantissaMask;
265 const bool MantissaKnownNotAllZeros = !(Bits.One & MantissaMask).isZero();
266
267 // Zero and subnormal require an exponent with all zero bits.
268 if (ExponentKnownNotAllZeros)
269 Known.knownNot(fcZero | fcSubnormal);
270
271 // Infinity and NaN require an exponent with all one bits.
272 if (ExponentKnownNotAllOnes)
273 Known.knownNot(fcInf | fcNan);
274
275 // Normal values have an exponent that is not all zeros or all ones.
276 if (ExponentKnownAllZeros || ExponentKnownAllOnes)
277 Known.knownNot(fcNormal);
278
279 // Zero and infinity require a mantissa with all zero bits.
280 if (MantissaKnownNotAllZeros)
281 Known.knownNot(fcZero | fcInf);
282
283 // Subnormal and NaN require a non-zero mantissa.
284 if (MantissaKnownAllZeros)
285 Known.knownNot(fcSubnormal | fcNan);
286
287 const bool QuietBitKnownSet = Bits.One[MantissaBits - 1];
288 const bool QuietBitKnownClear = Bits.Zero[MantissaBits - 1];
289
290 if (QuietBitKnownSet)
291 Known.knownNot(fcSNan);
292 else if (QuietBitKnownClear)
293 Known.knownNot(fcQNan);
294 }
295
296 return Known;
297}
298
300 KnownBits Known(FltSemantics.sizeInBits);
301 const FPClassTest FPClasses = getKnownFPClasses();
302
303 // Return unknown if poison.
304 if (FPClasses == fcNone)
305 return Known;
306
308 Known.setAllConflict();
309
310 if (FPClasses & fcInf)
311 Known = Known.intersectWith(KnownBits::makeConstant(
312 APFloat::getInf(FltSemantics).bitcastToAPInt()));
313
314 if (FPClasses & fcZero)
315 Known = Known.intersectWith(
317
318 Known.Zero.clearSignBit();
319 Known.One.clearSignBit();
320 }
321
322 if (std::optional<bool> Sign = getSignBit()) {
323 if (*Sign)
324 Known.makeNegative();
325 else
326 Known.makeNonNegative();
327 }
328
329 return Known;
330}
331
332// Handle known sign bit and nan cases for fadd.
333static KnownFPClass fadd_impl(const KnownFPClass &KnownLHS,
334 const KnownFPClass &KnownRHS, DenormalMode Mode) {
336
337 // Adding positive and negative infinity produces NaN, but only if both
338 // opposite-sign infinity combinations are possible.
339 if (KnownLHS.isKnownNeverNaN() && KnownRHS.isKnownNeverNaN() &&
340 (KnownLHS.isKnownNever(fcPosInf) || KnownRHS.isKnownNever(fcNegInf)) &&
341 (KnownLHS.isKnownNever(fcNegInf) || KnownRHS.isKnownNever(fcPosInf)))
342 Known.knownNot(fcNan);
343
344 if (KnownLHS.cannotBeOrderedLessThanZero() &&
345 KnownRHS.cannotBeOrderedLessThanZero()) {
347
348 // This can't underflow if one of the operands is known normal.
349 if (KnownLHS.isKnownNever(fcZero | fcPosSubnormal) ||
351 Known.knownNot(fcZero | fcPosSubnormal);
352 }
353
354 if (KnownLHS.cannotBeOrderedGreaterThanZero() &&
357
358 // This can't underflow if one of the operands is known normal.
359 if (KnownLHS.isKnownNever(fcZero | fcNegSubnormal) ||
361 Known.knownNot(fcZero | fcNegSubnormal);
362 }
363
364 return Known;
365}
366
368 const KnownFPClass &KnownRHS,
369 DenormalMode Mode) {
370 KnownFPClass Known = fadd_impl(KnownLHS, KnownRHS, Mode);
371
372 // (fadd x, 0.0) is guaranteed to return +0.0, not -0.0.
373 if ((KnownLHS.isKnownNeverLogicalNegZero(Mode) ||
374 KnownRHS.isKnownNeverLogicalNegZero(Mode)) &&
375 // Make sure output negative denormal can't flush to -0
376 (Mode.Output == DenormalMode::IEEE ||
377 Mode.Output == DenormalMode::PositiveZero))
378 Known.knownNot(fcNegZero);
379
380 return Known;
381}
382
384 DenormalMode Mode) {
385 KnownFPClass Known = fadd(KnownSrc, KnownSrc, Mode);
386
387 // Doubling 0 will give the same 0.
388 if (KnownSrc.isKnownNeverLogicalPosZero(Mode) &&
389 (Mode.Output == DenormalMode::IEEE ||
390 (Mode.Output == DenormalMode::PreserveSign &&
391 KnownSrc.isKnownNeverPosSubnormal()) ||
392 (Mode.Output == DenormalMode::PositiveZero &&
393 KnownSrc.isKnownNeverSubnormal())))
394 Known.knownNot(fcPosZero);
395
396 return Known;
397}
398
400 const KnownFPClass &KnownRHS,
401 DenormalMode Mode) {
402 return fadd(KnownLHS, fneg(KnownRHS), Mode);
403}
404
406 const KnownFPClass &KnownRHS,
407 DenormalMode Mode) {
409
410 // +X * +Y or -X * -Y => +Q
411 // +X * -Y or -X * +Y => -Q
412 Known.propagateXorSign(KnownLHS, KnownRHS);
413
414 // Inf * Y => Inf or NaN
415 if (KnownLHS.isKnownAlways(fcInf | fcNan) ||
416 KnownRHS.isKnownAlways(fcInf | fcNan))
417 Known.knownNot(fcNormal | fcSubnormal | fcZero);
418
419 // 0 * Y => 0 or NaN
420 if (KnownRHS.isKnownAlways(fcZero | fcNan) ||
421 KnownLHS.isKnownAlways(fcZero | fcNan))
422 Known.knownNot(fcNormal | fcSubnormal | fcInf);
423
424 if (!KnownLHS.isKnownNeverNaN() || !KnownRHS.isKnownNeverNaN())
425 return Known;
426
427 // 0 * +/-inf => NaN
428 if ((KnownRHS.isKnownNeverInfinity() ||
429 KnownLHS.isKnownNeverLogicalZero(Mode)) &&
430 (KnownLHS.isKnownNeverInfinity() ||
431 KnownRHS.isKnownNeverLogicalZero(Mode)))
432 Known.knownNot(fcNan);
433
434 return Known;
435}
436
437// TODO: This generalizes to known ranges
439 const APFloat &CRHS, DenormalMode Mode) {
440 // Match denormal scaling pattern, similar to the case in ldexp. If the
441 // constant's exponent is sufficiently large, the result cannot be subnormal.
442
443 const fltSemantics &Flt = CRHS.getSemantics();
444 unsigned Precision = APFloat::semanticsPrecision(Flt);
445 const int MantissaBits = Precision - 1;
446
447 int MinKnownExponent = ilogb(CRHS);
448 bool CannotBeSubnormal = (MinKnownExponent >= MantissaBits);
449
450 KnownFPClass Known = KnownFPClass::fmul(KnownLHS, KnownFPClass(CRHS), Mode);
451 if (CannotBeSubnormal)
452 Known.knownNot(fcSubnormal);
453
454 // Multiply of values <= 1 cannot introduce overflow.
455 if (KnownLHS.isKnownNever(fcInf)) {
456 if (MinKnownExponent < 0)
457 Known.knownNot(fcInf);
458 else if (MinKnownExponent == 0 && CRHS.compareAbsoluteValue(APFloat::getOne(
459 Flt)) == APFloat::cmpEqual)
460 Known.knownNot(fcInf);
461 }
462
463 return Known;
464}
465
467 const KnownFPClass &KnownRHS,
468 DenormalMode Mode) {
470
471 // Only 0/0, Inf/Inf produce NaN.
472 if (KnownLHS.isKnownNeverNaN() && KnownRHS.isKnownNeverNaN() &&
473 (KnownLHS.isKnownNeverInfinity() || KnownRHS.isKnownNeverInfinity()) &&
474 (KnownLHS.isKnownNeverLogicalZero(Mode) ||
475 KnownRHS.isKnownNeverLogicalZero(Mode))) {
476 Known.knownNot(fcNan);
477 }
478
479 // X / -0.0 => -Inf (or NaN)
480 // +X / +Y or -X / -Y => +Q
481 // +X / -Y or -X / +Y => -Q
482 Known.propagateXorSign(KnownLHS, KnownRHS);
483
484 // Normal and subnormal results require two non-zero finite operands.
485 if ((KnownLHS.isKnownNever(fcNegNormal | fcNegSubnormal) &&
489 Known.knownNot(fcNegNormal | fcNegSubnormal);
490 if ((KnownLHS.isKnownNever(fcNegNormal | fcNegSubnormal) &&
494 Known.knownNot(fcPosNormal | fcPosSubnormal);
495
496 // 0 / X => 0 or NaN
497 if (KnownLHS.isKnownAlways(fcZero))
498 Known.knownNot(fcSubnormal | fcNormal | fcInf);
499
500 // X / 0 => NaN or Inf
501 if (KnownRHS.isKnownAlways(fcZero))
502 Known.knownNot(fcFinite);
503
504 return Known;
505}
506
508 DenormalMode Mode) {
509 // X / X is always exactly 1.0 or a NaN.
511
512 if (KnownSrc.isKnownNeverInfOrNaN() && KnownSrc.isKnownNeverLogicalZero(Mode))
513 Known.knownNot(fcNan);
514 else if (KnownSrc.isKnownNever(fcSNan))
515 Known.knownNot(fcSNan);
516
517 return Known;
518}
519
521 const KnownFPClass &KnownRHS,
522 DenormalMode Mode) {
524
525 Known.knownNot(fcInf);
526
527 // Inf REM x and x REM 0 produce NaN.
528 if (KnownLHS.isKnownNeverNaN() && KnownRHS.isKnownNeverNaN() &&
529 KnownLHS.isKnownNeverInfinity() &&
530 KnownRHS.isKnownNeverLogicalZero(Mode)) {
531 Known.knownNot(fcNan);
532 }
533
534 // The sign for frem is the same as the first operand.
535 if (KnownLHS.cannotBeOrderedLessThanZero())
537 if (KnownLHS.cannotBeOrderedGreaterThanZero())
539
540 // See if we can be more aggressive about the sign of 0.
541 if (KnownLHS.isKnownNever(fcNegative))
542 Known.knownNot(fcNegative);
543 if (KnownLHS.isKnownNever(fcPositive))
544 Known.knownNot(fcPositive);
545
546 return Known;
547}
548
550 DenormalMode Mode) {
551 // X % X is always exactly [+-]0.0 or a NaN.
553
554 if (KnownSrc.isKnownNeverInfOrNaN() && KnownSrc.isKnownNeverLogicalZero(Mode))
555 Known.knownNot(fcNan);
556 else if (KnownSrc.isKnownNever(fcSNan))
557 Known.knownNot(fcSNan);
558
559 return Known;
560}
561
563 const KnownFPClass &KnownRHS,
564 const KnownFPClass &KnownAddend,
565 DenormalMode Mode) {
566 KnownFPClass Mul = fmul(KnownLHS, KnownRHS, Mode);
567
568 // FMA differs from the base fmul + fadd handling only in the treatment of -0
569 // results.
570 //
571 // If the multiply is a -0 due to rounding, the final -0 + 0 will be -0,
572 // unlike for a separate fadd.
573 return fadd_impl(Mul, KnownAddend, Mode);
574}
575
577 const KnownFPClass &KnownAddend,
578 DenormalMode Mode) {
579 KnownFPClass Squared = square(KnownSquared, Mode);
580 KnownFPClass Known = fadd_impl(Squared, KnownAddend, Mode);
581
582 // Since we know the squared input must be positive, the add of opposite sign
583 // infinities nan hazard only applies for negative inf.
584 //
585 // TODO: Alternatively to proving addend is not -inf, we could know Squared is
586 // not pinf. Other than the degenerate always-subnormal input case, we can't
587 // prove that without a known range.
588 if (KnownAddend.isKnownNever(fcNegInf | fcNan) && Squared.isKnownNever(fcNan))
589 Known.knownNot(fcNan);
590
591 return Known;
592}
593
596 Known.knownNot(fcNegative);
597
598 Known.propagateNonNaN(KnownSrc);
599
600 if (KnownSrc.cannotBeOrderedLessThanZero()) {
601 // If the source is positive this cannot underflow.
602 Known.knownNot(fcPosZero);
603
604 // Cannot introduce denormal values.
605 Known.knownNot(fcPosSubnormal);
606 }
607
608 // If the source is negative, this cannot overflow to infinity.
609 if (KnownSrc.cannotBeOrderedGreaterThanZero())
610 Known.knownNot(fcPosInf);
611
612 return Known;
613}
614
620
622 DenormalMode Mode) {
624 Known.knownNot(fcNegZero | fcSubnormal);
625
626 Known.propagateNonSNaN(KnownSrc);
627
628 if (KnownSrc.isKnownNeverPosInfinity())
629 Known.knownNot(fcPosInf);
630
631 if (KnownSrc.isKnownNeverNaN() && KnownSrc.cannotBeOrderedLessThanZero())
632 Known.knownNot(fcNan);
633
634 if (KnownSrc.isKnownNeverLogicalZero(Mode))
635 Known.knownNot(fcNegInf);
636
637 return Known;
638}
639
641 DenormalMode Mode) {
643 Known.knownNot(fcPosSubnormal);
644
645 if (KnownSrc.isKnownNeverPosInfinity())
646 Known.knownNot(fcPosInf);
647
648 Known.propagateNonSNaN(KnownSrc);
649
650 // Any negative value besides -0 returns a nan.
651 if (KnownSrc.isKnownNeverNaN() && KnownSrc.cannotBeOrderedLessThanZero())
652 Known.knownNot(fcNan);
653
654 // The only negative value that can be returned is -0 for -0 inputs.
656
657 // If the input denormal mode could be PreserveSign, a negative
658 // subnormal input could produce a negative zero output.
659 if (KnownSrc.isKnownNeverLogicalNegZero(Mode))
660 Known.knownNot(fcNegZero);
661
662 return Known;
663}
664
667
668 // Return NaN on infinite inputs.
669 Known.knownNot(fcInf);
670 if (KnownSrc.isKnownNeverNaN() && KnownSrc.isKnownNeverInfinity())
671 Known.knownNot(fcNan);
672
673 return Known;
674}
675
677 return sin(KnownSrc);
678}
679
682
683 // tan never returns Inf (tan(+-Inf) = NaN; tan(finite) = finite).
684 Known.knownNot(fcInf);
685
686 // NaN propagates. tan(+-Inf) is NaN.
687 if (KnownSrc.isKnownNeverNaN() && KnownSrc.isKnownNeverInfinity())
688 Known.knownNot(fcNan);
689
690 return Known;
691}
692
695
696 // sinh is sign-preserving: sinh(x) < 0 iff x < 0.
697 if (KnownSrc.isKnownNever(fcNegative))
698 Known.knownNot(fcNegative);
699
700 Known.propagateNonNaN(KnownSrc);
701
702 return Known;
703}
704
707
708 // cosh(x) >= 1 for all real x; cosh(+-Inf) = +Inf. Never negative,
709 // zero, or subnormal.
710 Known.knownNot(fcNegative | fcZero | fcSubnormal);
711
712 Known.propagateNonNaN(KnownSrc);
713
714 return Known;
715}
716
719
720 // tanh is bounded to (-1, 1), never Inf.
721 Known.knownNot(fcInf);
722
723 // tanh is sign-preserving: tanh(x) < 0 iff x < 0.
724 if (KnownSrc.isKnownNever(fcNegative))
725 Known.knownNot(fcNegative);
726
727 Known.propagateNonNaN(KnownSrc);
728
729 return Known;
730}
731
734
735 // asin is bounded to [-pi/2, pi/2], never Inf.
736 Known.knownNot(fcInf);
737
738 Known.propagateNonSNaN(KnownSrc);
739
740 // asin is sign-preserving for finite arguments.
741 if (KnownSrc.isKnownNever(fcNegFinite))
742 Known.knownNot(fcNegFinite);
743
744 // NaN propagates. asin(x) is also NaN for |x| > 1, so we cannot rule
745 // out NaN without knowing the source is in [-1, 1].
746 return Known;
747}
748
751
752 // acos(x) is bounded to [0, pi] for -1 <= x <= 1, and is never negative,
753 // infinite, or subnormal. The smallest non-zero value occurs when x is
754 // close to 1.0, where acos(x) can be approximated by sqrt(2 * (1 - x)).
755 // Since sqrt cannot produce a subnormal result, we can conclude that
756 // acos(x) will also never produce a subnormal result.
757 Known.knownNot(fcNegative | fcInf | fcSubnormal);
758
759 // acos(x) == +0.0 iff x == +1.0
760 if (KnownSrc.isKnownNever(fcPosNormal))
761 Known.knownNot(fcZero);
762
763 Known.propagateNonSNaN(KnownSrc);
764
765 // NaN propagates. acos(x) is also NaN for |x| > 1, so we cannot rule
766 // out NaN without knowing the source is in [-1, 1].
767 return Known;
768}
769
772
773 // atan is bounded to (-pi/2, pi/2), never Inf. atan(+-Inf) = +-pi/2 (finite).
774 Known.knownNot(fcInf);
775
776 // atan is sign-preserving: atan(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
786 const KnownFPClass &KnownX,
787 DenormalMode Mode) {
789
790 // Even though these deductions are correct, we are ignoring the following
791 // potentially erroneous cases:
792 // * atan2(y, inf) is not subnormal
793 // * atan2(inf, x) is not zero or subnormal
794
795 // atan2 result is in (-pi, pi], never Inf.
796 Known.knownNot(fcInf);
797
798 Known.propagateNonNaN(KnownY, KnownX);
799
800 // Negative subnormals could be treated like positive zero.
801 const bool XCannotHavePositiveValue = KnownX.isKnownNever(fcPositive) &&
802 KnownX.isKnownNeverLogicalPosZero(Mode);
803
804 // If x <= -0.0, then |atan2(y, x)| >= pi/2
805 if (XCannotHavePositiveValue)
806 Known.knownNot(fcZero | fcSubnormal);
807
808 return Known;
809}
810
812 const fltSemantics &DstTy,
813 const fltSemantics &SrcTy) {
814 // Infinity, nan and zero propagate from source.
815 KnownFPClass Known = KnownSrc;
816
817 // All subnormal inputs should be in the normal range in the result type.
818 if (APFloat::isRepresentableAsNormalIn(SrcTy, DstTy)) {
819 if (Known.getKnownFPClasses() & fcPosSubnormal)
820 Known.setKnownFPClasses(Known.getKnownFPClasses() | fcPosNormal);
821 if (Known.getKnownFPClasses() & fcNegSubnormal)
822 Known.setKnownFPClasses(Known.getKnownFPClasses() | fcNegNormal);
823 Known.knownNot(fcSubnormal);
824 }
825
826 // Sign bit of a nan isn't guaranteed.
827 if (!Known.isKnownNeverNaN())
828 Known.setSignBit(std::nullopt);
829
830 return Known;
831}
832
835
836 // Sign should be preserved
837 // TODO: Handle cannot be ordered greater than zero
838 if (KnownSrc.cannotBeOrderedLessThanZero())
840
841 Known.propagateNonNaN(KnownSrc);
842
843 // Infinity needs a range check.
844 return Known;
845}
846
848 bool IsTrunc,
849 bool IsMultiUnitFPType) {
851
852 // Integer results cannot be subnormal.
853 Known.knownNot(fcSubnormal);
854
855 Known.propagateNonNaN(KnownSrc);
856
857 // Pass through infinities, except PPC_FP128 is a special case for
858 // intrinsics other than trunc.
859 if (IsTrunc || !IsMultiUnitFPType) {
860 if (KnownSrc.isKnownNeverPosInfinity())
861 Known.knownNot(fcPosInf);
862 if (KnownSrc.isKnownNeverNegInfinity())
863 Known.knownNot(fcNegInf);
864 }
865
866 // Negative round ups to 0 produce -0
867 if (KnownSrc.isKnownNever(fcPosFinite))
868 Known.knownNot(fcPosFinite);
869 if (KnownSrc.isKnownNever(fcNegFinite))
870 Known.knownNot(fcNegFinite);
871
872 return Known;
873}
874
876 DenormalMode Mode) {
878 Known.knownNot(fcSubnormal);
879
880 if (KnownSrc.isKnownNever(fcNegative))
881 Known.knownNot(fcNegative);
882 else {
883 if (KnownSrc.isKnownNeverLogicalNegZero(Mode))
884 Known.knownNot(fcNegZero);
885 if (KnownSrc.isKnownNever(fcNegInf))
886 Known.knownNot(fcNegInf);
887 }
888
889 if (KnownSrc.isKnownNever(fcPositive))
890 Known.knownNot(fcPositive);
891 else {
892 if (KnownSrc.isKnownNeverLogicalPosZero(Mode))
893 Known.knownNot(fcPosZero);
894 if (KnownSrc.isKnownNever(fcPosInf))
895 Known.knownNot(fcPosInf);
896 }
897
898 Known.propagateNonNaN(KnownSrc);
899 return Known;
900}
901
903 const APInt &ConstantRangeExpMin,
904 const APInt &ConstantRangeExpMax,
905 const fltSemantics &Flt, DenormalMode Mode) {
907 Known.propagateNonNaN(KnownSrc);
908
909 // Sign is preserved, but underflows may produce zeroes.
910 if (KnownSrc.isKnownNever(fcNegative))
911 Known.knownNot(fcNegative);
912 else if (KnownSrc.cannotBeOrderedLessThanZero())
914
915 if (KnownSrc.isKnownNever(fcPositive))
916 Known.knownNot(fcPositive);
917 else if (KnownSrc.cannotBeOrderedGreaterThanZero())
919
920 unsigned Precision = APFloat::semanticsPrecision(Flt);
921 const int MantissaBits = Precision - 1;
922 if (ConstantRangeExpMin.sge(MantissaBits))
923 Known.knownNot(fcSubnormal);
924
925 if (ConstantRangeExpMin.isZero() && ConstantRangeExpMax.isZero()) {
926 // ldexp(x, 0) -> x, so propagate everything.
927 Known.propagateCanonicalizingSrc(KnownSrc, Mode);
928 } else if (ConstantRangeExpMax.isNonPositive()) {
929 // If we know the power is <= 0, can't introduce inf
930 if (KnownSrc.isKnownNeverPosInfinity())
931 Known.knownNot(fcPosInf);
932 if (KnownSrc.isKnownNeverNegInfinity())
933 Known.knownNot(fcNegInf);
934 } else if (ConstantRangeExpMin.isNonNegative()) {
935 // If we know the power is >= 0, can't introduce subnormal or zero
936 if (KnownSrc.isKnownNeverPosSubnormal())
937 Known.knownNot(fcPosSubnormal);
938 if (KnownSrc.isKnownNeverNegSubnormal())
939 Known.knownNot(fcNegSubnormal);
940 if (KnownSrc.isKnownNeverLogicalPosZero(Mode))
941 Known.knownNot(fcPosZero);
942 if (KnownSrc.isKnownNeverLogicalNegZero(Mode))
943 Known.knownNot(fcNegZero);
944 }
945
946 return Known;
947}
948
950 const KnownBits &ExpBits,
951 const fltSemantics &Flt, DenormalMode Mode) {
952 return ldexp(KnownSrc, ExpBits.getSignedMinValue(),
953 ExpBits.getSignedMaxValue(), Flt, Mode);
954}
955
957 const KnownFPClass &KnownRHS) {
959
960 Known.propagateNonSNaN(KnownLHS, KnownRHS);
961
962 // pow may return NaN if one of the arguments is NaN. NaN may be produced from
963 // a non-zero-finite-negative base and a non-integer exponent.
964 if (KnownLHS.isKnownNever(fcNan | fcNegNormal | fcNegSubnormal) &&
965 KnownRHS.isKnownNeverNaN())
966 Known.knownNot(fcNan);
967
968 // We could rule out negative and subnormal results when exponent is known to
969 // never be a normal value, but having either argument being known to never be
970 // normal is unlikely and not worth considering.
971
972 // Only a negative base raised to an odd power returns a negative value.
973 if (KnownLHS.isKnownNever(fcNegative)) {
974 Known.knownNot(fcNegative);
975 } else if (KnownLHS.isKnownNever(fcNegNormal | fcNegSubnormal)) {
976 Known.knownNot(fcNegNormal | fcNegSubnormal);
977 // See if we can also rule out -0.0 or -inf.
978 // Here at least one of -0.0 or -inf is a possible base.
979
980 // pow(-0.0, odd-positive) = -0.0
981 // pow(-inf, odd-negative) = -0.0
982 if ((KnownLHS.isKnownNever(fcNegZero) ||
983 KnownRHS.isKnownNever(fcPosNormal)) &&
984 (KnownLHS.isKnownNever(fcNegInf) || KnownRHS.isKnownNever(fcNegNormal)))
985 Known.knownNot(fcNegZero);
986
987 // pow(-0.0, odd-negative) = -inf
988 // pow(-inf, odd-positive) = -inf
989 if ((KnownLHS.isKnownNever(fcNegZero) ||
990 KnownRHS.isKnownNever(fcNegNormal)) &&
991 (KnownLHS.isKnownNever(fcNegInf) || KnownRHS.isKnownNever(fcPosNormal)))
992 Known.knownNot(fcNegInf);
993 }
994
995 return Known;
996}
997
999 const KnownBits &ExponentKnownBits) {
1001 Known.propagateNonNaN(KnownSrc);
1002
1003 if (ExponentKnownBits.isZero()) {
1004 // powi(QNaN, 0) returns 1.0, and powi(SNaN, 0) may non-deterministically
1005 // return 1.0 or a NaN.
1006 if (KnownSrc.isKnownNever(fcSNan)) {
1007 Known.knownNot(~fcPosNormal);
1008 return Known;
1009 }
1010
1011 Known.knownNot(~(fcPosNormal | fcNan));
1012 return Known;
1013 }
1014
1015 // Given that exp is an integer, here are the
1016 // ways that powi can return a negative value:
1017 //
1018 // powi(x, exp) --> negative if exp is odd and x is negative.
1019 // powi(-0, exp) --> -inf if exp is negative odd.
1020 // powi(-0, exp) --> -0 if exp is positive odd.
1021 // powi(-inf, exp) --> -0 if exp is negative odd.
1022 // powi(-inf, exp) --> -inf if exp is positive odd.
1023 if (KnownSrc.isKnownNever(fcNegative) || ExponentKnownBits.isEven()) {
1024 Known.knownNot(fcNegative);
1025 } else if (KnownSrc.isKnownNever(fcNegNormal | fcNegSubnormal)) {
1026 Known.knownNot(fcNegNormal | fcNegSubnormal);
1027 // See if we can also rule out -0.0 or -inf.
1028 // Here at least one of -0.0 or -inf is a possible base.
1029
1030 // We already know that ExponentKnownBits.isEven() is false here.
1031 const bool IsKnownNeverOddPositive = ExponentKnownBits.isNegative();
1032 const bool IsKnownNeverOddNegative = ExponentKnownBits.isNonNegative();
1033
1034 // powi(-0.0, odd-positive) = -0.0
1035 // powi(-inf, odd-negative) = -0.0
1036 if ((KnownSrc.isKnownNever(fcNegZero) || IsKnownNeverOddPositive) &&
1037 (KnownSrc.isKnownNever(fcNegInf) || IsKnownNeverOddNegative))
1038 Known.knownNot(fcNegZero);
1039
1040 // powi(-0.0, odd-negative) = -inf
1041 // powi(-inf, odd-positive) = -inf
1042 if ((KnownSrc.isKnownNever(fcNegZero) || IsKnownNeverOddNegative) &&
1043 (KnownSrc.isKnownNever(fcNegInf) || IsKnownNeverOddPositive))
1044 Known.knownNot(fcNegInf);
1045 }
1046
1047 // powi(x, exp) --> inf
1048 // when:
1049 // * powi(inf, exp), exp > 0
1050 // * powi(+/-0, exp), exp < 0
1051 // * powi(finite, exp), |exp| > 1
1052 // * powi(subnormal, -1)
1053 // TODO:
1054 // 1. This simple all or nothing approach. We can do better
1055 // and cover sign/parity and exp > 1 vs exp < -1 separately.
1056 // 2. powi(0/nan, exp), exp > 0 can be refinable
1057 // to fcNan | fcZero | fcPosNormal.
1058 {
1059 APInt MinExp = ExponentKnownBits.getSignedMinValue();
1060 APInt MaxExp = ExponentKnownBits.getSignedMaxValue();
1061
1062 // powi(inf, exp), exp > 0
1063 bool MayInfSrc =
1064 !KnownSrc.isKnownNever(fcInf) && MaxExp.isStrictlyPositive();
1065
1066 // powi(+/-0, exp), exp < 0
1067 bool MayDivByZero = !KnownSrc.isKnownNever(fcZero) && MinExp.isNegative();
1068
1069 // powi(finite, exp), |exp| > 1
1070 bool MayFinite = !KnownSrc.isKnownNever(fcNormal | fcSubnormal);
1071 bool MayAbsExpGT1 = MinExp.slt(-1) || MaxExp.sgt(1);
1072 bool MayFiniteOverflow = MayFinite && MayAbsExpGT1;
1073
1074 // powi(subnormal, -1)
1075 bool MayBeNegOne = ExponentKnownBits.Zero.isZero();
1076 bool MaySubnormInv = !KnownSrc.isKnownNever(fcSubnormal) && MayBeNegOne;
1077
1078 if (!MayInfSrc && !MayDivByZero && !MayFiniteOverflow && !MaySubnormInv)
1079 Known.knownNot(fcInf);
1080 }
1081
1082 return Known;
1083}
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 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