summaryrefslogtreecommitdiffstats
path: root/include/llvm/Constants.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-02 18:40:29 +0000
committerChris Lattner <sabre@nondot.org>2004-02-02 18:40:29 +0000
commitf0fd6845eee799f62ac69297c9fd7086a0156cfa (patch)
tree7ed55b82ed24bc8f5008c7b41a557437752c4ee6 /include/llvm/Constants.h
parent55d14de0cdc88650ea3cfdb30cf1e9b0111e7b65 (diff)
downloadexternal_llvm-f0fd6845eee799f62ac69297c9fd7086a0156cfa.zip
external_llvm-f0fd6845eee799f62ac69297c9fd7086a0156cfa.tar.gz
external_llvm-f0fd6845eee799f62ac69297c9fd7086a0156cfa.tar.bz2
Add a new method to ConstantFP
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11068 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Constants.h')
-rw-r--r--include/llvm/Constants.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 79b6322..2d6893a 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -283,6 +283,24 @@ public:
return T.I == 0;
}
+ /// isExactlyValue - We don't rely on operator== working on double values, as
+ /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
+ /// As such, this method can be used to do an exact bit-for-bit comparison of
+ /// two floating point values.
+ bool isExactlyValue(double V) const {
+ union {
+ double V;
+ uint64_t I;
+ } T1;
+ T1.V = Val;
+ union {
+ double V;
+ uint64_t I;
+ } T2;
+ T2.V = Val;
+ return T1.I == T2.I;
+ }
+
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantFP *) { return true; }
static bool classof(const Constant *CPV); // defined in Constants.cpp