aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/APFloat.cpp
diff options
context:
space:
mode:
authorSamuel Parker <sam.parker@arm.com>2023-01-30 12:17:11 +0000
committerSamuel Parker <sam.parker@arm.com>2023-01-30 12:25:25 +0000
commit038f7debfda01471ce0d4eb1fed20da61e5c8b32 (patch)
treebd39ffcb8ffba22d5dff70feae7c7ea422653ee4 /llvm/lib/Support/APFloat.cpp
parent7bf5f62574e23ba56447aca2530197d8577b59fd (diff)
downloadllvm-038f7debfda01471ce0d4eb1fed20da61e5c8b32.zip
llvm-038f7debfda01471ce0d4eb1fed20da61e5c8b32.tar.gz
llvm-038f7debfda01471ce0d4eb1fed20da61e5c8b32.tar.bz2
[DAGCombine] fp_to_sint isSaturatingMinMax
Recommitting after fixing scalable vector crash. 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.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index 9a8feba..e9998d7 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;