summaryrefslogtreecommitdiff
path: root/include/llvm/Constants.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-09 00:03:58 +0000
committerChris Lattner <sabre@nondot.org>2008-04-09 00:03:58 +0000
commitdef286408f4ddd0511164d231dfeddcc5fe12008 (patch)
tree741d9c91a6604ea56d1a917f078ddba91bf2f921 /include/llvm/Constants.h
parentcba931f6010e56f061ed04fe75f6b70906edfdc9 (diff)
downloadllvm-def286408f4ddd0511164d231dfeddcc5fe12008.tar.gz
llvm-def286408f4ddd0511164d231dfeddcc5fe12008.tar.bz2
llvm-def286408f4ddd0511164d231dfeddcc5fe12008.tar.xz
make ConstantFP::isExactlyValue work for long double as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49410 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Constants.h')
-rw-r--r--include/llvm/Constants.h11
1 files changed, 4 insertions, 7 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 13df601f41..b7c16e4f8c 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -251,16 +251,13 @@ public:
/// As such, this method can be used to do an exact bit-for-bit comparison of
/// two floating point values. The version with a double operand is retained
/// because it's so convenient to write isExactlyValue(2.0), but please use
- /// it only for constants.
+ /// it only for simple constants.
bool isExactlyValue(const APFloat& V) const;
bool isExactlyValue(double V) const {
- if (&Val.getSemantics() == &APFloat::IEEEdouble)
- return isExactlyValue(APFloat(V));
- else if (&Val.getSemantics() == &APFloat::IEEEsingle)
- return isExactlyValue(APFloat((float)V));
- assert(0);
- return false;
+ APFloat FV(V);
+ FV.convert(Val.getSemantics(), APFloat::rmNearestTiesToEven);
+ return isExactlyValue(FV);
}
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantFP *) { return true; }