diff options
author | Alex Bradbury <asb@lowrisc.org> | 2017-11-21 12:00:19 +0000 |
---|---|---|
committer | Alex Bradbury <asb@lowrisc.org> | 2017-11-21 12:00:19 +0000 |
commit | 9caefe364af0e60e31d30a0fd45ad1b5616283c0 (patch) | |
tree | d3a5789514741c894c95b6ca19f4f8b5d33eac8f /llvm | |
parent | 51d82696db3c1c8fe44eafbce5cb578353f9aec3 (diff) | |
download | bcm5719-llvm-9caefe364af0e60e31d30a0fd45ad1b5616283c0.tar.gz bcm5719-llvm-9caefe364af0e60e31d30a0fd45ad1b5616283c0.zip |
[RISCV][NFC] Clean up RISCVDAGToDAGISel::Select
As pointed out in post-commit review of r318738, `return ReplaceNode(..)` when
both ReplaceNode and the current function return void is confusing. This patch
moves to using a more obvious early return, and moves to just using an if to
catch the one case we currently care about. A future patch that adds further
custom instruction selection can introduce a switch.
llvm-svn: 318757
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp index 97ad7a571c8..5b038df4ae3 100644 --- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp @@ -65,21 +65,16 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) { // 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 == XLenVT) { - ConstantSDNode *ConstNode = cast<ConstantSDNode>(Node); - // Materialize zero constants as copies from X0. This allows the coalescer - // to propagate these into other instructions. - if (ConstNode->isNullValue()) { - SDValue New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), - SDLoc(Node), RISCV::X0, XLenVT); - return ReplaceNode(Node, New.getNode()); - } + if (Opcode == ISD::Constant && VT == XLenVT) { + auto *ConstNode = cast<ConstantSDNode>(Node); + // Materialize zero constants as copies from X0. This allows the coalescer + // to propagate these into other instructions. + if (ConstNode->isNullValue()) { + SDValue New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), SDLoc(Node), + RISCV::X0, XLenVT); + ReplaceNode(Node, New.getNode()); + return; } - break; - default: - break; } // Select the default instruction. |