diff options
author | Samuel Parker <sam.parker@arm.com> | 2023-01-26 11:52:24 +0000 |
---|---|---|
committer | Samuel Parker <sam.parker@arm.com> | 2023-01-26 12:37:43 +0000 |
commit | 85395af27241ab9c8d5763b8afcaa07f1bab26d5 (patch) | |
tree | 3646aa27ceb2e5cff03b48965fa32c4cc13c4f22 /llvm/lib/Support/APFloat.cpp | |
parent | dd9cf8a5d13450b920795e6d1ef6fd5dbbebb3d7 (diff) | |
download | llvm-85395af27241ab9c8d5763b8afcaa07f1bab26d5.zip llvm-85395af27241ab9c8d5763b8afcaa07f1bab26d5.tar.gz llvm-85395af27241ab9c8d5763b8afcaa07f1bab26d5.tar.bz2 |
[DAGCombine] fp_to_sint isSaturatingMinMax
Check for single smax pattern against zero when converting from a
small enough float.
Differential Revision: https://reviews.llvm.org/D142481
Diffstat (limited to 'llvm/lib/Support/APFloat.cpp')
-rw-r--r-- | llvm/lib/Support/APFloat.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index eae4fdb..cdeed3e 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -251,6 +251,16 @@ namespace llvm { unsigned int APFloatBase::semanticsSizeInBits(const fltSemantics &semantics) { return semantics.sizeInBits; } + unsigned int APFloatBase::semanticsIntSizeInBits(const fltSemantics &semantics, + bool isSigned) { + // The max FP value is pow(2, MaxExponent) * (1 + MaxFraction), so we need + // at least one more bit than the MaxExponent to hold the max FP value. + unsigned int MinBitWidth = semanticsMaxExponent(semantics) + 1; + // Extra sign bit needed. + if (isSigned) + ++MinBitWidth; + return MinBitWidth; + } unsigned APFloatBase::getSizeInBits(const fltSemantics &Sem) { return Sem.sizeInBits; |