[llvm] r318757 - [RISCV][NFC] Clean up RISCVDAGToDAGISel::Select
Alex Bradbury via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 21 04:00:20 PST 2017
Author: asb
Date: Tue Nov 21 04:00:19 2017
New Revision: 318757
URL: http://llvm.org/viewvc/llvm-project?rev=318757&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
Modified: llvm/trunk/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/RISCVISelDAGToDAG.cpp?rev=318757&r1=318756&r2=318757&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/RISCVISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/RISCV/RISCVISelDAGToDAG.cpp Tue Nov 21 04:00:19 2017
@@ -65,21 +65,16 @@ void RISCVDAGToDAGISel::Select(SDNode *N
// 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.
More information about the llvm-commits
mailing list