[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Mar 5 15:58:11 PST 2006
Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAG.cpp updated: 1.268 -> 1.269
---
Log message:
Don't depend on the C99 copysign function, implement it ourselves.
---
Diffs of the changes: (+17 -7)
SelectionDAG.cpp | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.268 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.269
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.268 Sun Mar 5 15:43:37 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sun Mar 5 17:57:58 2006
@@ -29,11 +29,6 @@
#include <algorithm>
using namespace llvm;
-#ifdef _MSC_VER
-#include <float.h>
-#define copysign _copysign
-#endif
-
static bool isCommutativeBinOp(unsigned Opcode) {
switch (Opcode) {
case ISD::ADD:
@@ -1255,8 +1250,23 @@
case ISD::FREM :
if (C2) return getConstantFP(fmod(C1, C2), VT);
break;
- case ISD::FCOPYSIGN:
- return getConstantFP(copysign(C1, C2), VT);
+ case ISD::FCOPYSIGN: {
+ union {
+ double F;
+ uint64_t I;
+ } u1;
+ union {
+ double F;
+ int64_t I;
+ } u2;
+ u1.F = C1;
+ u2.F = C2;
+ if (u2.I < 0) // Sign bit of RHS set?
+ u1.I |= 1ULL << 63; // Set the sign bit of the LHS.
+ else
+ u1.I &= (1ULL << 63)-1; // Clear the sign bit of the LHS.
+ return getConstantFP(u1.F, VT);
+ }
default: break;
}
} else { // Cannonicalize constant to RHS if commutative
More information about the llvm-commits
mailing list