[llvm-commits] CVS: llvm/include/llvm/Constants.h

Jim Laskey jlaskey at apple.com
Wed Aug 17 12:19:27 PDT 2005



Changes in directory llvm/include/llvm:

Constants.h updated: 1.70 -> 1.71
---
Log message:

Culling out use of unions for converting FP to bits and vice versa.



---
Diffs of the changes:  (+3 -17)

 Constants.h |   20 +++-----------------
 1 files changed, 3 insertions(+), 17 deletions(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.70 llvm/include/llvm/Constants.h:1.71
--- llvm/include/llvm/Constants.h:1.70	Thu Apr 21 15:11:51 2005
+++ llvm/include/llvm/Constants.h	Wed Aug 17 14:19:16 2005
@@ -23,6 +23,7 @@
 #include "llvm/Constant.h"
 #include "llvm/Type.h"
 #include "llvm/Support/DataTypes.h"
+#include "llvm/Support/MathExtras.h"
 
 namespace llvm {
 
@@ -277,12 +278,7 @@
   /// getNullValue.  Don't depend on == for doubles to tell us it's zero, it
   /// considers -0.0 to be null as well as 0.0.  :(
   virtual bool isNullValue() const {
-    union {
-      double V;
-      uint64_t I;
-    } T;
-    T.V = Val;
-    return T.I == 0;
+    return DoubleToBits(Val) == 0;
   }
 
   /// isExactlyValue - We don't rely on operator== working on double values, as
@@ -290,17 +286,7 @@
   /// 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 = V;
-    return T1.I == T2.I;
+    return DoubleToBits(V) == DoubleToBits(Val);
   }
 
   /// Methods for support type inquiry through isa, cast, and dyn_cast:






More information about the llvm-commits mailing list