diff options
Diffstat (limited to 'contrib/llvm/lib/Target/Lanai/LanaiISelDAGToDAG.cpp')
-rw-r--r-- | contrib/llvm/lib/Target/Lanai/LanaiISelDAGToDAG.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/contrib/llvm/lib/Target/Lanai/LanaiISelDAGToDAG.cpp b/contrib/llvm/lib/Target/Lanai/LanaiISelDAGToDAG.cpp index 29bc6e8..ed0c99a 100644 --- a/contrib/llvm/lib/Target/Lanai/LanaiISelDAGToDAG.cpp +++ b/contrib/llvm/lib/Target/Lanai/LanaiISelDAGToDAG.cpp @@ -56,7 +56,7 @@ public: } // Pass Name - const char *getPassName() const override { + StringRef getPassName() const override { return "Lanai DAG->DAG Pattern Instruction Selection"; } @@ -282,9 +282,29 @@ void LanaiDAGToDAGISel::Select(SDNode *Node) { return; } - // Instruction Selection not handled by the auto-generated - // tablegen selection should be handled here. + // Instruction Selection not handled by the auto-generated tablegen selection + // should be handled here. + EVT VT = Node->getValueType(0); switch (Opcode) { + case ISD::Constant: + if (VT == MVT::i32) { + ConstantSDNode *ConstNode = cast<ConstantSDNode>(Node); + // Materialize zero constants as copies from R0. This allows the coalescer + // to propagate these into other instructions. + if (ConstNode->isNullValue()) { + SDValue New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), + SDLoc(Node), Lanai::R0, MVT::i32); + return ReplaceNode(Node, New.getNode()); + } + // Materialize all ones constants as copies from R1. This allows the + // coalescer to propagate these into other instructions. + if (ConstNode->isAllOnesValue()) { + SDValue New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), + SDLoc(Node), Lanai::R1, MVT::i32); + return ReplaceNode(Node, New.getNode()); + } + } + break; case ISD::FrameIndex: selectFrameIndex(Node); return; |