mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-30 02:32:08 +00:00
- Add support for 6-, 12-, and 18-bit limited precision floating-point "log"
values. - Refactored some of the code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56008 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5530216989
commit
3915025a4f
@ -2738,6 +2738,37 @@ void AddCatchInfo(CallInst &I, MachineModuleInfo *MMI,
|
||||
|
||||
}
|
||||
|
||||
// GetSignificand - Get the significand and build it into a floating-point
|
||||
// number with exponent of 1:
|
||||
//
|
||||
// Op = (Op & 0x007fffff) | 0x3f800000;
|
||||
//
|
||||
// where Op is the hexidecimal representation of floating point value.
|
||||
static SDValue
|
||||
GetSignificand(SelectionDAG &DAG, SDValue Op) {
|
||||
SDValue t1 = DAG.getNode(ISD::AND, MVT::i32, Op,
|
||||
DAG.getConstant(0x007fffff, MVT::i32));
|
||||
SDValue t2 = DAG.getNode(ISD::OR, MVT::i32, t1,
|
||||
DAG.getConstant(0x3f800000, MVT::i32));
|
||||
return DAG.getNode(ISD::BIT_CONVERT, MVT::f32, t2);
|
||||
}
|
||||
|
||||
// GetExponent - Get the exponent:
|
||||
//
|
||||
// (float)(((Op1 & 0x7f800000) >> 23) - 127);
|
||||
//
|
||||
// where Op is the hexidecimal representation of floating point value.
|
||||
static SDValue
|
||||
GetExponent(SelectionDAG &DAG, SDValue Op) {
|
||||
SDValue t1 = DAG.getNode(ISD::AND, MVT::i32, Op,
|
||||
DAG.getConstant(0x7f800000, MVT::i32));
|
||||
SDValue t2 = DAG.getNode(ISD::SRL, MVT::i32, t1,
|
||||
DAG.getConstant(23, MVT::i32));
|
||||
SDValue t3 = DAG.getNode(ISD::SUB, MVT::i32, t2,
|
||||
DAG.getConstant(127, MVT::i32));
|
||||
return DAG.getNode(ISD::UINT_TO_FP, MVT::f32, t3);
|
||||
}
|
||||
|
||||
/// Inlined utility function to implement binary input atomic intrinsics for
|
||||
/// visitIntrinsicCall: I is a call instruction
|
||||
/// Op is the associated NodeType for I
|
||||
@ -2765,15 +2796,125 @@ SelectionDAGLowering::visitExp(CallInst &I) {
|
||||
setValue(&I, result);
|
||||
}
|
||||
|
||||
/// visitLog - lower a log intrinsic. Handles the special sequences
|
||||
/// for limited-precision mode.
|
||||
/// visitLog - Lower a log intrinsic. Handles the special sequences for
|
||||
/// limited-precision mode.
|
||||
void
|
||||
SelectionDAGLowering::visitLog(CallInst &I) {
|
||||
SDValue result;
|
||||
// No special expansion.
|
||||
result = DAG.getNode(ISD::FLOG,
|
||||
getValue(I.getOperand(1)).getValueType(),
|
||||
getValue(I.getOperand(1)));
|
||||
|
||||
if (getValue(I.getOperand(1)).getValueType() == MVT::f32 &&
|
||||
LimitFloatPrecision > 0 && LimitFloatPrecision <= 18) {
|
||||
SDValue Op = getValue(I.getOperand(1));
|
||||
SDValue Op1 = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, Op);
|
||||
|
||||
// Scale the exponent by log(2) [0.69314718f].
|
||||
SDValue Exp = GetExponent(DAG, Op1);
|
||||
SDValue LogOfExponent = DAG.getNode(ISD::FMUL, MVT::f32, Exp,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3f317218)), MVT::f32));
|
||||
|
||||
// Get the significand and build it into a floating-point number with
|
||||
// exponent of 1.
|
||||
SDValue X = GetSignificand(DAG, Op1);
|
||||
|
||||
if (LimitFloatPrecision <= 6) {
|
||||
// For floating-point precision of 6:
|
||||
//
|
||||
// LogofMantissa =
|
||||
// -1.1609546f +
|
||||
// (1.4034025f - 0.23903021f * x) * x;
|
||||
//
|
||||
// error 0.0034276066, which is better than 8 bits
|
||||
SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0xbe74c456)), MVT::f32));
|
||||
SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3fb3a2b1)), MVT::f32));
|
||||
SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
|
||||
SDValue LogOfMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t2,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3f949a29)), MVT::f32));
|
||||
|
||||
result = DAG.getNode(ISD::FADD, MVT::f32, LogOfExponent, LogOfMantissa);
|
||||
} else if (LimitFloatPrecision > 6 && LimitFloatPrecision <= 12) {
|
||||
// For floating-point precision of 12:
|
||||
//
|
||||
// LogOfMantissa =
|
||||
// -1.7417939f +
|
||||
// (2.8212026f +
|
||||
// (-1.4699568f +
|
||||
// (0.44717955f - 0.56570851e-1f * x) * x) * x) * x;
|
||||
//
|
||||
// error 0.000061011436, which is 14 bits
|
||||
SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0xbd67b6d6)), MVT::f32));
|
||||
SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3ee4f4b8)), MVT::f32));
|
||||
SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
|
||||
SDValue t3 = DAG.getNode(ISD::FSUB, MVT::f32, t2,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3fbc278b)), MVT::f32));
|
||||
SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
|
||||
SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x40348e95)), MVT::f32));
|
||||
SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
|
||||
SDValue LogOfMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t6,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3fdef31a)), MVT::f32));
|
||||
|
||||
result = DAG.getNode(ISD::FADD, MVT::f32, LogOfExponent, LogOfMantissa);
|
||||
} else { // LimitFloatPrecision > 12 && LimitFloatPrecision <= 18
|
||||
// For floating-point precision of 18:
|
||||
//
|
||||
// LogOfMantissa =
|
||||
// -2.1072184f +
|
||||
// (4.2372794f +
|
||||
// (-3.7029485f +
|
||||
// (2.2781945f +
|
||||
// (-0.87823314f +
|
||||
// (0.19073739f - 0.17809712e-1f * x) * x) * x) * x) * x)*x;
|
||||
//
|
||||
// error 0.0000023660568, which is better than 18 bits
|
||||
SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0xbc91e5ac)), MVT::f32));
|
||||
SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3e4350aa)), MVT::f32));
|
||||
SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
|
||||
SDValue t3 = DAG.getNode(ISD::FSUB, MVT::f32, t2,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3f60d3e3)), MVT::f32));
|
||||
SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
|
||||
SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x4011cdf0)), MVT::f32));
|
||||
SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
|
||||
SDValue t7 = DAG.getNode(ISD::FSUB, MVT::f32, t6,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x406cfd1c)), MVT::f32));
|
||||
SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, t7, X);
|
||||
SDValue t9 = DAG.getNode(ISD::FADD, MVT::f32, t8,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x408797cb)), MVT::f32));
|
||||
SDValue t10 = DAG.getNode(ISD::FMUL, MVT::f32, t9, X);
|
||||
SDValue LogOfMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t10,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x4006dcab)), MVT::f32));
|
||||
|
||||
result = DAG.getNode(ISD::FADD, MVT::f32, LogOfExponent, LogOfMantissa);
|
||||
}
|
||||
} else {
|
||||
// No special expansion.
|
||||
result = DAG.getNode(ISD::FLOG,
|
||||
getValue(I.getOperand(1)).getValueType(),
|
||||
getValue(I.getOperand(1)));
|
||||
}
|
||||
|
||||
setValue(&I, result);
|
||||
}
|
||||
|
||||
@ -2788,30 +2929,12 @@ SelectionDAGLowering::visitLog2(CallInst &I) {
|
||||
SDValue Op = getValue(I.getOperand(1));
|
||||
SDValue Op1 = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, Op);
|
||||
|
||||
// Get the exponent, which is most of log and scale by log(2):
|
||||
//
|
||||
// LogOfExponent = (float) (((Op1 & 0x7f800000) >> 23) - 127);
|
||||
//
|
||||
// where Op1 is the hexidecimal representation of floating point value.
|
||||
SDValue t0 = DAG.getNode(ISD::AND, MVT::i32, Op1,
|
||||
DAG.getConstant(0x7f800000, MVT::i32));
|
||||
SDValue t1 = DAG.getNode(ISD::SRL, MVT::i32, t0,
|
||||
DAG.getConstant(23, MVT::i32));
|
||||
SDValue t2 = DAG.getNode(ISD::SUB, MVT::i32, t1,
|
||||
DAG.getConstant(127, MVT::i32));
|
||||
SDValue LogOfExponent = DAG.getNode(ISD::UINT_TO_FP, MVT::f32, t2);
|
||||
// Get the exponent.
|
||||
SDValue LogOfExponent = GetExponent(DAG, Op1);
|
||||
|
||||
// Get the significand and build it into a floating-point number with
|
||||
// exponent of 1:
|
||||
//
|
||||
// Op1 = (Op1 & 0x007fffff) | 0x3f800000;
|
||||
//
|
||||
// where Op1 is the hexidecimal representation of floating point value.
|
||||
SDValue t4 = DAG.getNode(ISD::AND, MVT::i32, Op1,
|
||||
DAG.getConstant(0x007fffff, MVT::i32));
|
||||
SDValue t5 = DAG.getNode(ISD::OR, MVT::i32, t4,
|
||||
DAG.getConstant(0x3f800000, MVT::i32));
|
||||
SDValue X = DAG.getNode(ISD::BIT_CONVERT, MVT::f32, t5);
|
||||
// exponent of 1.
|
||||
SDValue X = GetSignificand(DAG, Op1);
|
||||
|
||||
// Different possible minimax approximations of significand in
|
||||
// floating-point for various degrees of accuracy over [1,2].
|
||||
@ -2821,14 +2944,14 @@ SelectionDAGLowering::visitLog2(CallInst &I) {
|
||||
// Log2ofMantissa = -1.6749035f + (2.0246817f - .34484768f * x) * x;
|
||||
//
|
||||
// error 0.0049451742, which is more than 7 bits
|
||||
SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0xbeb08fe0)), MVT::f32));
|
||||
SDValue t9 = DAG.getNode(ISD::FADD, MVT::f32, t8,
|
||||
SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x40019463)), MVT::f32));
|
||||
SDValue t10 = DAG.getNode(ISD::FMUL, MVT::f32, t9, X);
|
||||
SDValue Log2ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t10,
|
||||
SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
|
||||
SDValue Log2ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t2,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3fd6633d)), MVT::f32));
|
||||
|
||||
@ -2843,22 +2966,22 @@ SelectionDAGLowering::visitLog2(CallInst &I) {
|
||||
// (.645142248f - 0.816157886e-1f * x) * x) * x) * x;
|
||||
//
|
||||
// error 0.0000876136000, which is better than 13 bits
|
||||
SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0xbda7262e)), MVT::f32));
|
||||
SDValue t9 = DAG.getNode(ISD::FADD, MVT::f32, t8,
|
||||
SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3f25280b)), MVT::f32));
|
||||
SDValue t10 = DAG.getNode(ISD::FMUL, MVT::f32, t9, X);
|
||||
SDValue t11 = DAG.getNode(ISD::FSUB, MVT::f32, t10,
|
||||
SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
|
||||
SDValue t3 = DAG.getNode(ISD::FSUB, MVT::f32, t2,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x4007b923)), MVT::f32));
|
||||
SDValue t12 = DAG.getNode(ISD::FMUL, MVT::f32, t11, X);
|
||||
SDValue t13 = DAG.getNode(ISD::FADD, MVT::f32, t12,
|
||||
SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
|
||||
SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x40823e2f)), MVT::f32));
|
||||
SDValue t14 = DAG.getNode(ISD::FMUL, MVT::f32, t13, X);
|
||||
SDValue Log2ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t14,
|
||||
SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
|
||||
SDValue Log2ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t6,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x4020d29c)), MVT::f32));
|
||||
|
||||
@ -2876,30 +2999,30 @@ SelectionDAGLowering::visitLog2(CallInst &I) {
|
||||
// 0.25691327e-1f * x) * x) * x) * x) * x) * x;
|
||||
//
|
||||
// error 0.0000018516, which is better than 18 bits
|
||||
SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0xbcd2769e)), MVT::f32));
|
||||
SDValue t9 = DAG.getNode(ISD::FADD, MVT::f32, t8,
|
||||
SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3e8ce0b9)), MVT::f32));
|
||||
SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
|
||||
SDValue t3 = DAG.getNode(ISD::FSUB, MVT::f32, t2,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3fa22ae7)), MVT::f32));
|
||||
SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
|
||||
SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x40525723)), MVT::f32));
|
||||
SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
|
||||
SDValue t7 = DAG.getNode(ISD::FSUB, MVT::f32, t6,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x40aaf200)), MVT::f32));
|
||||
SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, t7, X);
|
||||
SDValue t9 = DAG.getNode(ISD::FADD, MVT::f32, t8,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x40c39dad)), MVT::f32));
|
||||
SDValue t10 = DAG.getNode(ISD::FMUL, MVT::f32, t9, X);
|
||||
SDValue t11 = DAG.getNode(ISD::FSUB, MVT::f32, t10,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3fa22ae7)), MVT::f32));
|
||||
SDValue t12 = DAG.getNode(ISD::FMUL, MVT::f32, t11, X);
|
||||
SDValue t13 = DAG.getNode(ISD::FADD, MVT::f32, t12,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x40525723)), MVT::f32));
|
||||
SDValue t14 = DAG.getNode(ISD::FMUL, MVT::f32, t13, X);
|
||||
SDValue t15 = DAG.getNode(ISD::FSUB, MVT::f32, t14,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x40aaf200)), MVT::f32));
|
||||
SDValue t16 = DAG.getNode(ISD::FMUL, MVT::f32, t15, X);
|
||||
SDValue t17 = DAG.getNode(ISD::FADD, MVT::f32, t16,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x40c39dad)), MVT::f32));
|
||||
SDValue t18 = DAG.getNode(ISD::FMUL, MVT::f32, t17, X);
|
||||
SDValue Log2ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t18,
|
||||
SDValue Log2ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t10,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x4042902c)), MVT::f32));
|
||||
|
||||
@ -2925,34 +3048,15 @@ SelectionDAGLowering::visitLog10(CallInst &I) {
|
||||
SDValue Op = getValue(I.getOperand(1));
|
||||
SDValue Op1 = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, Op);
|
||||
|
||||
// Get the exponent, which is most of log10 and scale by log10(2).
|
||||
//
|
||||
// #define LOG10OF2 0.30102999f
|
||||
// Log10ofExponent = (float)(((Op1 & 0x7f800000) >> 23) - 127) * LOG10OF2;
|
||||
//
|
||||
// where Op1 is the hexidecimal value of the floating-point number.
|
||||
SDValue t0 = DAG.getNode(ISD::AND, MVT::i32, Op1,
|
||||
DAG.getConstant(0x7f800000, MVT::i32));
|
||||
SDValue t1 = DAG.getNode(ISD::SRL, MVT::i32, t0,
|
||||
DAG.getConstant(23, MVT::i32));
|
||||
SDValue t2 = DAG.getNode(ISD::SUB, MVT::i32, t1,
|
||||
DAG.getConstant(127, MVT::i32));
|
||||
SDValue t3 = DAG.getNode(ISD::UINT_TO_FP, MVT::f32, t2);
|
||||
SDValue LogOfExponent = DAG.getNode(ISD::FMUL, MVT::f32, t3,
|
||||
// Scale the exponent by log10(2) [0.30102999f].
|
||||
SDValue Exp = GetExponent(DAG, Op1);
|
||||
SDValue LogOfExponent = DAG.getNode(ISD::FMUL, MVT::f32, Exp,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3e9a209a)), MVT::f32));
|
||||
|
||||
// Get the significand and build it into a floating-point number with
|
||||
// exponent of 1:
|
||||
//
|
||||
// Op1 = (Op1 & 0x007fffff) | 0x3f800000;
|
||||
//
|
||||
// where Op1 is the hexidecimal representation of floating point value.
|
||||
SDValue t4 = DAG.getNode(ISD::AND, MVT::i32, Op1,
|
||||
DAG.getConstant(0x007fffff, MVT::i32));
|
||||
SDValue t5 = DAG.getNode(ISD::OR, MVT::i32, t4,
|
||||
DAG.getConstant(0x3f800000, MVT::i32));
|
||||
SDValue X = DAG.getNode(ISD::BIT_CONVERT, MVT::f32, t5);
|
||||
// exponent of 1.
|
||||
SDValue X = GetSignificand(DAG, Op1);
|
||||
|
||||
if (LimitFloatPrecision <= 6) {
|
||||
// For floating-point precision of 6:
|
||||
@ -2962,14 +3066,14 @@ SelectionDAGLowering::visitLog10(CallInst &I) {
|
||||
// (0.60948995f - 0.10380950f * x) * x;
|
||||
//
|
||||
// error 0.0014886165, which is 6 bits
|
||||
SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0xbdd49a13)), MVT::f32));
|
||||
SDValue t7 = DAG.getNode(ISD::FADD, MVT::f32, t6,
|
||||
SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3f1c0789)), MVT::f32));
|
||||
SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, t7, X);
|
||||
SDValue Log10ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t8,
|
||||
SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
|
||||
SDValue Log10ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t2,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3f011300)), MVT::f32));
|
||||
|
||||
@ -2983,18 +3087,18 @@ SelectionDAGLowering::visitLog10(CallInst &I) {
|
||||
// (-0.31664806f + 0.47637168e-1f * x) * x) * x;
|
||||
//
|
||||
// error 0.00019228036, which is better than 12 bits
|
||||
SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3d431f31)), MVT::f32));
|
||||
SDValue t7 = DAG.getNode(ISD::FSUB, MVT::f32, t6,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3ea21fb2)), MVT::f32));
|
||||
SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, t7, X);
|
||||
SDValue t9 = DAG.getNode(ISD::FADD, MVT::f32, t8,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3f6ae232)), MVT::f32));
|
||||
SDValue t10 = DAG.getNode(ISD::FMUL, MVT::f32, t9, X);
|
||||
SDValue Log10ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t10,
|
||||
SDValue t1 = DAG.getNode(ISD::FSUB, MVT::f32, t0,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3ea21fb2)), MVT::f32));
|
||||
SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
|
||||
SDValue t3 = DAG.getNode(ISD::FADD, MVT::f32, t2,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3f6ae232)), MVT::f32));
|
||||
SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
|
||||
SDValue Log10ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t4,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3f25f7c3)), MVT::f32));
|
||||
|
||||
@ -3010,26 +3114,26 @@ SelectionDAGLowering::visitLog10(CallInst &I) {
|
||||
// (-0.12539807f + 0.13508273e-1f * x) * x) * x) * x) * x;
|
||||
//
|
||||
// error 0.0000037995730, which is better than 18 bits
|
||||
SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3c5d51ce)), MVT::f32));
|
||||
SDValue t7 = DAG.getNode(ISD::FSUB, MVT::f32, t6,
|
||||
SDValue t1 = DAG.getNode(ISD::FSUB, MVT::f32, t0,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3e00685a)), MVT::f32));
|
||||
SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
|
||||
SDValue t3 = DAG.getNode(ISD::FADD, MVT::f32, t2,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3efb6798)), MVT::f32));
|
||||
SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
|
||||
SDValue t5 = DAG.getNode(ISD::FSUB, MVT::f32, t4,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3f88d192)), MVT::f32));
|
||||
SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
|
||||
SDValue t7 = DAG.getNode(ISD::FADD, MVT::f32, t6,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3fc4316c)), MVT::f32));
|
||||
SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, t7, X);
|
||||
SDValue t9 = DAG.getNode(ISD::FADD, MVT::f32, t8,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3efb6798)), MVT::f32));
|
||||
SDValue t10 = DAG.getNode(ISD::FMUL, MVT::f32, t9, X);
|
||||
SDValue t11 = DAG.getNode(ISD::FSUB, MVT::f32, t10,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3f88d192)), MVT::f32));
|
||||
SDValue t12 = DAG.getNode(ISD::FMUL, MVT::f32, t11, X);
|
||||
SDValue t13 = DAG.getNode(ISD::FADD, MVT::f32, t12,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3fc4316c)), MVT::f32));
|
||||
SDValue t14 = DAG.getNode(ISD::FMUL, MVT::f32, t13, X);
|
||||
SDValue Log10ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t14,
|
||||
SDValue Log10ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t8,
|
||||
DAG.getConstantFP(APFloat(
|
||||
APInt(32, 0x3f57ce70)), MVT::f32));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user