diff options
author | Dan Gohman <gohman@apple.com> | 2009-08-10 23:15:10 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-08-10 23:15:10 +0000 |
commit | 733a64db570d56c0eaeb7dcee81ea6e5f069be0e (patch) | |
tree | faec31697ca6a70084f8098a96018eb1a946f071 | |
parent | d9aedcae2316914efb6ea91c32695aee13f35066 (diff) | |
download | bcm5719-llvm-733a64db570d56c0eaeb7dcee81ea6e5f069be0e.tar.gz bcm5719-llvm-733a64db570d56c0eaeb7dcee81ea6e5f069be0e.zip |
Fix a bug where DAGCombine was producing an illegal ConstantFP
node after legalize, and remove the workaround code from the
ARM backend.
llvm-svn: 78615
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp | 18 |
2 files changed, 12 insertions, 19 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 6119411d360..42d163f79b1 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3721,7 +3721,18 @@ SDValue DAGCombiner::visitBIT_CONVERT(SDNode *N) { // If the input is a constant, let getNode fold it. if (isa<ConstantSDNode>(N0) || isa<ConstantFPSDNode>(N0)) { SDValue Res = DAG.getNode(ISD::BIT_CONVERT, N->getDebugLoc(), VT, N0); - if (Res.getNode() != N) return Res; + if (Res.getNode() != N) { + if (!LegalOperations || + TLI.isOperationLegal(Res.getNode()->getOpcode(), VT)) + return Res; + + // Folding it resulted in an illegal node, and it's too late to + // do that. Clean up the old node and forego the transformation. + // Ideally this won't happen very often, because instcombine + // and the earlier dagcombine runs (where illegal nodes are + // permitted) should have folded most of them already. + DAG.DeleteNode(Res.getNode()); + } } // (conv (conv x, t1), t2) -> (conv x, t2) diff --git a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp index 07575290c1d..1096e8eb01c 100644 --- a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp +++ b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp @@ -988,24 +988,6 @@ SDNode *ARMDAGToDAGISel::Select(SDValue Op) { // Other cases are autogenerated. break; } - case ISD::ConstantFP: { - ConstantFPSDNode *CFP = cast<ConstantFPSDNode>(N); - EVT VT = CFP->getValueType(0); - ConstantFP *LLVMC = const_cast<ConstantFP*>(CFP->getConstantFPValue()); - SDValue CPIdx = CurDAG->getTargetConstantPool(LLVMC, TLI.getPointerTy()); - SDNode *ResNode; - SDValue Ops[] = { - CPIdx, - CurDAG->getTargetConstant(0, EVT::i32), - getAL(CurDAG), - CurDAG->getRegister(0, EVT::i32), - CurDAG->getEntryNode() - }; - unsigned Opc = (VT == EVT::f32) ? ARM::FLDS : ARM::FLDD; - ResNode=CurDAG->getTargetNode(Opc, dl, VT, EVT::Other, Ops, 5); - ReplaceUses(Op, SDValue(ResNode, 0)); - return NULL; - } case ISD::FrameIndex: { // Selects to ADDri FI, 0 which in turn will become ADDri SP, imm. int FI = cast<FrameIndexSDNode>(N)->getIndex(); |