mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 21:32:39 +00:00
Don't depend on the C99 copysign function, implement it ourselves.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26566 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
03182bfd89
commit
3c232c83be
@ -29,11 +29,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include <float.h>
|
|
||||||
#define copysign _copysign
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool isCommutativeBinOp(unsigned Opcode) {
|
static bool isCommutativeBinOp(unsigned Opcode) {
|
||||||
switch (Opcode) {
|
switch (Opcode) {
|
||||||
case ISD::ADD:
|
case ISD::ADD:
|
||||||
@ -1255,8 +1250,23 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
|
|||||||
case ISD::FREM :
|
case ISD::FREM :
|
||||||
if (C2) return getConstantFP(fmod(C1, C2), VT);
|
if (C2) return getConstantFP(fmod(C1, C2), VT);
|
||||||
break;
|
break;
|
||||||
case ISD::FCOPYSIGN:
|
case ISD::FCOPYSIGN: {
|
||||||
return getConstantFP(copysign(C1, C2), VT);
|
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;
|
default: break;
|
||||||
}
|
}
|
||||||
} else { // Cannonicalize constant to RHS if commutative
|
} else { // Cannonicalize constant to RHS if commutative
|
||||||
|
Loading…
x
Reference in New Issue
Block a user