Skip to content

Commit 5ca39a5

Browse files
committed
[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.
1 parent 373571d commit 5ca39a5

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,8 +1942,7 @@ bool RISCVDAGToDAGISel::selectShiftMask(SDValue N, unsigned ShiftWidth,
19421942
if (Imm != 0 && Imm % ShiftWidth == 0) {
19431943
SDLoc DL(N);
19441944
EVT VT = N.getValueType();
1945-
SDValue Zero =
1946-
CurDAG->getCopyFromReg(CurDAG->getEntryNode(), DL, RISCV::X0, VT);
1945+
SDValue Zero = CurDAG->getRegister(RISCV::X0, VT);
19471946
unsigned NegOpc = VT == MVT::i64 ? RISCV::SUBW : RISCV::SUB;
19481947
MachineSDNode *Neg = CurDAG->getMachineNode(NegOpc, DL, VT, Zero,
19491948
N.getOperand(1));

0 commit comments

Comments
 (0)