[llvm-commits] [llvm] r55856 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
Dale Johannesen
dalej at apple.com
Fri Sep 5 14:27:19 PDT 2008
Author: johannes
Date: Fri Sep 5 16:27:19 2008
New Revision: 55856
URL: http://llvm.org/viewvc/llvm-project?rev=55856&view=rev
Log:
Add the next limited-precision expansion.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=55856&r1=55855&r2=55856&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Fri Sep 5 16:27:19 2008
@@ -2798,10 +2798,49 @@
void
SelectionDAGLowering::visitLog10(CallInst &I) {
SDValue result;
+ if (getValue(I.getOperand(1)).getValueType() == MVT::f32 &&
+ LimitFloatPrecision>0 && LimitFloatPrecision<=12) {
+ SDValue operand = getValue(I.getOperand(1));
+ SDValue operand1 = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, operand);
+ SDValue t0 = DAG.getNode(ISD::SRL, MVT::i32, operand1,
+ DAG.getConstant(23, MVT::i32));
+ SDValue t1 = DAG.getNode(ISD::AND, MVT::i32, t0,
+ DAG.getConstant(255, 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 t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3,
+ DAG.getConstantFP(APFloat(
+ APInt(32, 0x3e9a209a)), MVT::f32));
+ SDValue t5 = DAG.getNode(ISD::OR, MVT::i32, operand1,
+ DAG.getConstant(1065353216, MVT::i32));
+ SDValue t6 = DAG.getNode(ISD::AND, MVT::i32, t5,
+ DAG.getConstant(1073741823, MVT::i32));
+ SDValue t7 = DAG.getNode(ISD::BIT_CONVERT, MVT::f32, t6);
+ SDValue t8 = DAG.getNode(ISD::FP_EXTEND, MVT::f64, t7);
+ SDValue t9 = DAG.getNode(ISD::FMUL, MVT::f64, t8,
+ DAG.getConstantFP(APFloat(
+ APInt(64, 0x3fa863e61d44a337ULL)), MVT::f64));
+ SDValue t10 = DAG.getNode(ISD::FSUB, MVT::f64, t9,
+ DAG.getConstantFP(APFloat(
+ APInt(64, 0x3fd443f63982ad9aULL)), MVT::f64));
+ SDValue t11 = DAG.getNode(ISD::FMUL, MVT::f64, t10, t8);
+ SDValue t12 = DAG.getNode(ISD::FADD, MVT::f64, t11,
+ DAG.getConstantFP(APFloat(
+ APInt(64, 0x3fed5c4641d8bd71ULL)), MVT::f64));
+ SDValue t13 = DAG.getNode(ISD::FMUL, MVT::f64, t12, t8);
+ SDValue t14 = DAG.getNode(ISD::FSUB, MVT::f64, t13,
+ DAG.getConstantFP(APFloat(
+ APInt(64, 0x3fe4bef863538c6fULL)), MVT::f64));
+ SDValue t15 = DAG.getNode(ISD::FP_ROUND, MVT::f32, t14,
+ DAG.getConstant(0, MVT::i32));
+ result = DAG.getNode(ISD::FADD, MVT::f32, t4, t15);
+ } else {
// No special expansion.
- result = DAG.getNode(ISD::FLOG10,
- getValue(I.getOperand(1)).getValueType(),
- getValue(I.getOperand(1)));
+ result = DAG.getNode(ISD::FLOG10,
+ getValue(I.getOperand(1)).getValueType(),
+ getValue(I.getOperand(1)));
+ }
setValue(&I, result);
}
More information about the llvm-commits
mailing list