From 5ca39a55a7ea383cdf4a557689af741027b0f3db Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 30 Jun 2022 15:10:31 -0700 Subject: [PATCH] [RISCV] Remove an unnecessary copy of X0 in selectShiftMask. We know which instruction we're emitting so its ok to directly encode X0 into the instruction. We only need to create a copy when a constant 0 is selected without context of what instructions uses it. --- llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp index 6ce8f61..ba146f8 100644 --- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp @@ -1942,8 +1942,7 @@ bool RISCVDAGToDAGISel::selectShiftMask(SDValue N, unsigned ShiftWidth, if (Imm != 0 && Imm % ShiftWidth == 0) { SDLoc DL(N); EVT VT = N.getValueType(); - SDValue Zero = - CurDAG->getCopyFromReg(CurDAG->getEntryNode(), DL, RISCV::X0, VT); + SDValue Zero = CurDAG->getRegister(RISCV::X0, VT); unsigned NegOpc = VT == MVT::i64 ? RISCV::SUBW : RISCV::SUB; MachineSDNode *Neg = CurDAG->getMachineNode(NegOpc, DL, VT, Zero, N.getOperand(1)); -- 2.7.4