diff options
author | Serge Pavlov <sepavloff@gmail.com> | 2021-05-07 02:17:42 +0700 |
---|---|---|
committer | Serge Pavlov <sepavloff@gmail.com> | 2021-05-21 11:02:51 +0700 |
commit | c162f086ba632ffaedfe92d63bf21571bc8ae4da (patch) | |
tree | 6798043c54cf97d5db4d936c36fe7b689aaace48 /llvm/lib/Analysis/ConstantFolding.cpp | |
parent | 49028858637946ce8c00f12e41138b5ed7783276 (diff) | |
download | llvm-c162f086ba632ffaedfe92d63bf21571bc8ae4da.zip llvm-c162f086ba632ffaedfe92d63bf21571bc8ae4da.tar.gz llvm-c162f086ba632ffaedfe92d63bf21571bc8ae4da.tar.bz2 |
[APFloat] convertToDouble/Float can work on shorter types
Previously APFloat::convertToDouble may be called only for APFloats that
were built using double semantics. Other semantics like single precision
were not allowed although corresponding numbers could be converted to
double without loss of precision. The similar restriction applied to
APFloat::convertToFloat.
With this change any APFloat that can be precisely represented by double
can be handled with convertToDouble. Behavior of convertToFloat was
updated similarly. It make the conversion operations more convenient and
adds support for formats like half and bfloat.
Differential Revision: https://reviews.llvm.org/D102671
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index d09e4b8..62dbf9f 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -1794,10 +1794,7 @@ Constant *ConstantFoldSSEConvertToInt(const APFloat &Val, bool roundTowardZero, double getValueAsDouble(ConstantFP *Op) { Type *Ty = Op->getType(); - if (Ty->isFloatTy()) - return Op->getValueAPF().convertToFloat(); - - if (Ty->isDoubleTy()) + if (Ty->isBFloatTy() || Ty->isHalfTy() || Ty->isFloatTy() || Ty->isDoubleTy()) return Op->getValueAPF().convertToDouble(); bool unused; |