LLVM 22.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
16
17using namespace llvm;
18
19/// Return true if it's possible to assume IEEE treatment of input denormals in
20/// \p F for \p Val.
22 return Mode.Input == DenormalMode::IEEE;
23}
24
29
34
39
42 return false;
43
44 // If we know there are no denormals, nothing can be flushed to zero.
46 return true;
47
48 switch (Mode.Input) {
50 return true;
52 // Negative subnormal won't flush to +0
55 default:
56 // Both positive and negative subnormal could flush to +0
57 return false;
58 }
59
60 llvm_unreachable("covered switch over denormal mode");
61}
62
64 DenormalMode Mode) {
65 KnownFPClasses = Src.KnownFPClasses;
66 // If we aren't assuming the source can't be a zero, we don't have to check if
67 // a denormal input could be flushed.
68 if (!Src.isKnownNeverPosZero() && !Src.isKnownNeverNegZero())
69 return;
70
71 // If we know the input can't be a denormal, it can't be flushed to 0.
72 if (Src.isKnownNeverSubnormal())
73 return;
74
75 if (!Src.isKnownNeverPosSubnormal() && Mode != DenormalMode::getIEEE())
77
78 if (!Src.isKnownNeverNegSubnormal() && Mode != DenormalMode::getIEEE()) {
81
82 if (Mode.Input == DenormalMode::PositiveZero ||
83 Mode.Output == DenormalMode::PositiveZero ||
84 Mode.Input == DenormalMode::Dynamic ||
85 Mode.Output == DenormalMode::Dynamic)
87 }
88}
89
91 DenormalMode Mode) {
92 propagateDenormal(Src, Mode);
93 propagateNaN(Src, /*PreserveSign=*/true);
94}
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 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")))
#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.
Represent subnormal handling kind for floating point instruction inputs and outputs.
@ 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()
static constexpr DenormalMode getIEEE()
FPClassTest KnownFPClasses
Floating-point classes the value could be one of.
bool isKnownNeverZero() const
Return true if it's known this can never be a zero.
bool isKnownNeverSubnormal() const
Return true if it's known this can never be a subnormal.
LLVM_ABI bool isKnownNeverLogicalZero(DenormalMode Mode) const
Return true if it's know this can never be interpreted as a zero.
LLVM_ABI void propagateDenormal(const KnownFPClass &Src, DenormalMode Mode)
Propagate knowledge from a source value that could be a denormal or zero.
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.
bool isKnownNeverNegZero() const
Return true if it's known this can never be a negative zero.
void propagateNaN(const KnownFPClass &Src, bool PreserveSign=false)
LLVM_ABI void propagateCanonicalizingSrc(const KnownFPClass &Src, DenormalMode Mode)
Report known classes if Src is evaluated through a potentially canonicalizing operation.
LLVM_ABI bool isKnownNeverLogicalPosZero(DenormalMode Mode) const
Return true if it's know this can never be interpreted as a positive zero.
LLVM_ABI bool isKnownNeverLogicalNegZero(DenormalMode Mode) const
Return true if it's know this can never be interpreted as a negative zero.
bool isKnownNeverPosSubnormal() const
Return true if it's known this can never be a positive subnormal.