[llvm] 5ca39a5 - [RISCV] Remove an unnecessary copy of X0 in selectShiftMask.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 30 15:12:38 PDT 2022


Author: Craig Topper
Date: 2022-06-30T15:11:58-07:00
New Revision: 5ca39a55a7ea383cdf4a557689af741027b0f3db

URL: https://github.com/llvm/llvm-project/commit/5ca39a55a7ea383cdf4a557689af741027b0f3db
DIFF: https://github.com/llvm/llvm-project/commit/5ca39a55a7ea383cdf4a557689af741027b0f3db.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
index 6ce8f61e9e090..ba146f883b39f 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));


        


More information about the llvm-commits mailing list