[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Apr 1 21:27:21 PST 2005
Changes in directory llvm/lib/CodeGen/SelectionDAG:
LegalizeDAG.cpp updated: 1.70 -> 1.71
---
Log message:
Expand fabs into fneg
---
Diffs of the changes: (+9 -1)
LegalizeDAG.cpp | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletion(-)
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.70 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.71
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.70 Fri Apr 1 23:00:07 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Apr 1 23:26:37 2005
@@ -887,8 +887,16 @@
Tmp2 = DAG.getConstantFP(-0.0, Node->getValueType(0));
Result = LegalizeOp(DAG.getNode(ISD::SUB, Node->getValueType(0),
Tmp2, Tmp1));
+ } else if (Node->getOpcode() == ISD::FABS) {
+ // Expand Y = FABS(X) -> Y = (X >u 0.0) ? X : fneg(X).
+ MVT::ValueType VT = Node->getValueType(0);
+ Tmp2 = DAG.getConstantFP(0.0, VT);
+ Tmp2 = DAG.getSetCC(ISD::SETUGT, TLI.getSetCCResultTy(), Tmp1, Tmp2);
+ Tmp3 = DAG.getNode(ISD::FNEG, VT, Tmp1);
+ Result = DAG.getNode(ISD::SELECT, VT, Tmp2, Tmp1, Tmp3);
+ Result = LegalizeOp(Result);
} else {
- assert(0 && "Expand fneg not impl yet!");
+ assert(0 && "Unreachable!");
}
break;
}
More information about the llvm-commits
mailing list