mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Factor out the final FADD that's common to multiple code paths in the visitLog* functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168183 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
79dcd43600
commit
df0ea8dcad
@ -3834,6 +3834,7 @@ SelectionDAGBuilder::visitLog(const CallInst &I) {
|
|||||||
// exponent of 1.
|
// exponent of 1.
|
||||||
SDValue X = GetSignificand(DAG, Op1, dl);
|
SDValue X = GetSignificand(DAG, Op1, dl);
|
||||||
|
|
||||||
|
SDValue LogOfMantissa;
|
||||||
if (LimitFloatPrecision <= 6) {
|
if (LimitFloatPrecision <= 6) {
|
||||||
// For floating-point precision of 6:
|
// For floating-point precision of 6:
|
||||||
//
|
//
|
||||||
@ -3847,11 +3848,8 @@ SelectionDAGBuilder::visitLog(const CallInst &I) {
|
|||||||
SDValue t1 = DAG.getNode(ISD::FADD, dl, MVT::f32, t0,
|
SDValue t1 = DAG.getNode(ISD::FADD, dl, MVT::f32, t0,
|
||||||
getF32Constant(DAG, 0x3fb3a2b1));
|
getF32Constant(DAG, 0x3fb3a2b1));
|
||||||
SDValue t2 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t1, X);
|
SDValue t2 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t1, X);
|
||||||
SDValue LogOfMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t2,
|
LogOfMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t2,
|
||||||
getF32Constant(DAG, 0x3f949a29));
|
getF32Constant(DAG, 0x3f949a29));
|
||||||
|
|
||||||
result = DAG.getNode(ISD::FADD, dl,
|
|
||||||
MVT::f32, LogOfExponent, LogOfMantissa);
|
|
||||||
} else if (LimitFloatPrecision > 6 && LimitFloatPrecision <= 12) {
|
} else if (LimitFloatPrecision > 6 && LimitFloatPrecision <= 12) {
|
||||||
// For floating-point precision of 12:
|
// For floating-point precision of 12:
|
||||||
//
|
//
|
||||||
@ -3873,11 +3871,8 @@ SelectionDAGBuilder::visitLog(const CallInst &I) {
|
|||||||
SDValue t5 = DAG.getNode(ISD::FADD, dl, MVT::f32, t4,
|
SDValue t5 = DAG.getNode(ISD::FADD, dl, MVT::f32, t4,
|
||||||
getF32Constant(DAG, 0x40348e95));
|
getF32Constant(DAG, 0x40348e95));
|
||||||
SDValue t6 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t5, X);
|
SDValue t6 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t5, X);
|
||||||
SDValue LogOfMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t6,
|
LogOfMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t6,
|
||||||
getF32Constant(DAG, 0x3fdef31a));
|
getF32Constant(DAG, 0x3fdef31a));
|
||||||
|
|
||||||
result = DAG.getNode(ISD::FADD, dl,
|
|
||||||
MVT::f32, LogOfExponent, LogOfMantissa);
|
|
||||||
} else { // LimitFloatPrecision > 12 && LimitFloatPrecision <= 18
|
} else { // LimitFloatPrecision > 12 && LimitFloatPrecision <= 18
|
||||||
// For floating-point precision of 18:
|
// For floating-point precision of 18:
|
||||||
//
|
//
|
||||||
@ -3907,12 +3902,12 @@ SelectionDAGBuilder::visitLog(const CallInst &I) {
|
|||||||
SDValue t9 = DAG.getNode(ISD::FADD, dl, MVT::f32, t8,
|
SDValue t9 = DAG.getNode(ISD::FADD, dl, MVT::f32, t8,
|
||||||
getF32Constant(DAG, 0x408797cb));
|
getF32Constant(DAG, 0x408797cb));
|
||||||
SDValue t10 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t9, X);
|
SDValue t10 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t9, X);
|
||||||
SDValue LogOfMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t10,
|
LogOfMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t10,
|
||||||
getF32Constant(DAG, 0x4006dcab));
|
getF32Constant(DAG, 0x4006dcab));
|
||||||
|
|
||||||
result = DAG.getNode(ISD::FADD, dl,
|
|
||||||
MVT::f32, LogOfExponent, LogOfMantissa);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = DAG.getNode(ISD::FADD, dl,
|
||||||
|
MVT::f32, LogOfExponent, LogOfMantissa);
|
||||||
} else {
|
} else {
|
||||||
// No special expansion.
|
// No special expansion.
|
||||||
result = DAG.getNode(ISD::FLOG, dl,
|
result = DAG.getNode(ISD::FLOG, dl,
|
||||||
@ -3944,6 +3939,7 @@ SelectionDAGBuilder::visitLog2(const CallInst &I) {
|
|||||||
|
|
||||||
// Different possible minimax approximations of significand in
|
// Different possible minimax approximations of significand in
|
||||||
// floating-point for various degrees of accuracy over [1,2].
|
// floating-point for various degrees of accuracy over [1,2].
|
||||||
|
SDValue Log2ofMantissa;
|
||||||
if (LimitFloatPrecision <= 6) {
|
if (LimitFloatPrecision <= 6) {
|
||||||
// For floating-point precision of 6:
|
// For floating-point precision of 6:
|
||||||
//
|
//
|
||||||
@ -3955,11 +3951,8 @@ SelectionDAGBuilder::visitLog2(const CallInst &I) {
|
|||||||
SDValue t1 = DAG.getNode(ISD::FADD, dl, MVT::f32, t0,
|
SDValue t1 = DAG.getNode(ISD::FADD, dl, MVT::f32, t0,
|
||||||
getF32Constant(DAG, 0x40019463));
|
getF32Constant(DAG, 0x40019463));
|
||||||
SDValue t2 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t1, X);
|
SDValue t2 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t1, X);
|
||||||
SDValue Log2ofMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t2,
|
Log2ofMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t2,
|
||||||
getF32Constant(DAG, 0x3fd6633d));
|
getF32Constant(DAG, 0x3fd6633d));
|
||||||
|
|
||||||
result = DAG.getNode(ISD::FADD, dl,
|
|
||||||
MVT::f32, LogOfExponent, Log2ofMantissa);
|
|
||||||
} else if (LimitFloatPrecision > 6 && LimitFloatPrecision <= 12) {
|
} else if (LimitFloatPrecision > 6 && LimitFloatPrecision <= 12) {
|
||||||
// For floating-point precision of 12:
|
// For floating-point precision of 12:
|
||||||
//
|
//
|
||||||
@ -3981,11 +3974,8 @@ SelectionDAGBuilder::visitLog2(const CallInst &I) {
|
|||||||
SDValue t5 = DAG.getNode(ISD::FADD, dl, MVT::f32, t4,
|
SDValue t5 = DAG.getNode(ISD::FADD, dl, MVT::f32, t4,
|
||||||
getF32Constant(DAG, 0x40823e2f));
|
getF32Constant(DAG, 0x40823e2f));
|
||||||
SDValue t6 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t5, X);
|
SDValue t6 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t5, X);
|
||||||
SDValue Log2ofMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t6,
|
Log2ofMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t6,
|
||||||
getF32Constant(DAG, 0x4020d29c));
|
getF32Constant(DAG, 0x4020d29c));
|
||||||
|
|
||||||
result = DAG.getNode(ISD::FADD, dl,
|
|
||||||
MVT::f32, LogOfExponent, Log2ofMantissa);
|
|
||||||
} else { // LimitFloatPrecision > 12 && LimitFloatPrecision <= 18
|
} else { // LimitFloatPrecision > 12 && LimitFloatPrecision <= 18
|
||||||
// For floating-point precision of 18:
|
// For floating-point precision of 18:
|
||||||
//
|
//
|
||||||
@ -4016,12 +4006,12 @@ SelectionDAGBuilder::visitLog2(const CallInst &I) {
|
|||||||
SDValue t9 = DAG.getNode(ISD::FADD, dl, MVT::f32, t8,
|
SDValue t9 = DAG.getNode(ISD::FADD, dl, MVT::f32, t8,
|
||||||
getF32Constant(DAG, 0x40c39dad));
|
getF32Constant(DAG, 0x40c39dad));
|
||||||
SDValue t10 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t9, X);
|
SDValue t10 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t9, X);
|
||||||
SDValue Log2ofMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t10,
|
Log2ofMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t10,
|
||||||
getF32Constant(DAG, 0x4042902c));
|
getF32Constant(DAG, 0x4042902c));
|
||||||
|
|
||||||
result = DAG.getNode(ISD::FADD, dl,
|
|
||||||
MVT::f32, LogOfExponent, Log2ofMantissa);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = DAG.getNode(ISD::FADD, dl,
|
||||||
|
MVT::f32, LogOfExponent, Log2ofMantissa);
|
||||||
} else {
|
} else {
|
||||||
// No special expansion.
|
// No special expansion.
|
||||||
result = DAG.getNode(ISD::FLOG2, dl,
|
result = DAG.getNode(ISD::FLOG2, dl,
|
||||||
@ -4053,6 +4043,7 @@ SelectionDAGBuilder::visitLog10(const CallInst &I) {
|
|||||||
// exponent of 1.
|
// exponent of 1.
|
||||||
SDValue X = GetSignificand(DAG, Op1, dl);
|
SDValue X = GetSignificand(DAG, Op1, dl);
|
||||||
|
|
||||||
|
SDValue Log10ofMantissa;
|
||||||
if (LimitFloatPrecision <= 6) {
|
if (LimitFloatPrecision <= 6) {
|
||||||
// For floating-point precision of 6:
|
// For floating-point precision of 6:
|
||||||
//
|
//
|
||||||
@ -4066,11 +4057,8 @@ SelectionDAGBuilder::visitLog10(const CallInst &I) {
|
|||||||
SDValue t1 = DAG.getNode(ISD::FADD, dl, MVT::f32, t0,
|
SDValue t1 = DAG.getNode(ISD::FADD, dl, MVT::f32, t0,
|
||||||
getF32Constant(DAG, 0x3f1c0789));
|
getF32Constant(DAG, 0x3f1c0789));
|
||||||
SDValue t2 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t1, X);
|
SDValue t2 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t1, X);
|
||||||
SDValue Log10ofMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t2,
|
Log10ofMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t2,
|
||||||
getF32Constant(DAG, 0x3f011300));
|
getF32Constant(DAG, 0x3f011300));
|
||||||
|
|
||||||
result = DAG.getNode(ISD::FADD, dl,
|
|
||||||
MVT::f32, LogOfExponent, Log10ofMantissa);
|
|
||||||
} else if (LimitFloatPrecision > 6 && LimitFloatPrecision <= 12) {
|
} else if (LimitFloatPrecision > 6 && LimitFloatPrecision <= 12) {
|
||||||
// For floating-point precision of 12:
|
// For floating-point precision of 12:
|
||||||
//
|
//
|
||||||
@ -4088,11 +4076,8 @@ SelectionDAGBuilder::visitLog10(const CallInst &I) {
|
|||||||
SDValue t3 = DAG.getNode(ISD::FADD, dl, MVT::f32, t2,
|
SDValue t3 = DAG.getNode(ISD::FADD, dl, MVT::f32, t2,
|
||||||
getF32Constant(DAG, 0x3f6ae232));
|
getF32Constant(DAG, 0x3f6ae232));
|
||||||
SDValue t4 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t3, X);
|
SDValue t4 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t3, X);
|
||||||
SDValue Log10ofMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t4,
|
Log10ofMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t4,
|
||||||
getF32Constant(DAG, 0x3f25f7c3));
|
getF32Constant(DAG, 0x3f25f7c3));
|
||||||
|
|
||||||
result = DAG.getNode(ISD::FADD, dl,
|
|
||||||
MVT::f32, LogOfExponent, Log10ofMantissa);
|
|
||||||
} else { // LimitFloatPrecision > 12 && LimitFloatPrecision <= 18
|
} else { // LimitFloatPrecision > 12 && LimitFloatPrecision <= 18
|
||||||
// For floating-point precision of 18:
|
// For floating-point precision of 18:
|
||||||
//
|
//
|
||||||
@ -4118,12 +4103,12 @@ SelectionDAGBuilder::visitLog10(const CallInst &I) {
|
|||||||
SDValue t7 = DAG.getNode(ISD::FADD, dl, MVT::f32, t6,
|
SDValue t7 = DAG.getNode(ISD::FADD, dl, MVT::f32, t6,
|
||||||
getF32Constant(DAG, 0x3fc4316c));
|
getF32Constant(DAG, 0x3fc4316c));
|
||||||
SDValue t8 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t7, X);
|
SDValue t8 = DAG.getNode(ISD::FMUL, dl, MVT::f32, t7, X);
|
||||||
SDValue Log10ofMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t8,
|
Log10ofMantissa = DAG.getNode(ISD::FSUB, dl, MVT::f32, t8,
|
||||||
getF32Constant(DAG, 0x3f57ce70));
|
getF32Constant(DAG, 0x3f57ce70));
|
||||||
|
|
||||||
result = DAG.getNode(ISD::FADD, dl,
|
|
||||||
MVT::f32, LogOfExponent, Log10ofMantissa);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = DAG.getNode(ISD::FADD, dl,
|
||||||
|
MVT::f32, LogOfExponent, Log10ofMantissa);
|
||||||
} else {
|
} else {
|
||||||
// No special expansion.
|
// No special expansion.
|
||||||
result = DAG.getNode(ISD::FLOG10, dl,
|
result = DAG.getNode(ISD::FLOG10, dl,
|
||||||
|
Loading…
Reference in New Issue
Block a user