Skip to content

Commit 65eb468

Browse files
authored
[RISCV] Explicitly create IMPLICIT_DEF instead of UNDEF for vectors i… (llvm#67369)
…n RISCVDAGToDAGISel::Select. UNDEF needs to go through isel itself. All of the nodes have been topologically sorted so that instruction selection precedes from root to entry node. If we create a new node that needs to go through isel, we have to insert it into the correct place in the topological sort. If we don't, it might not get selected at all in some cases. Some targets have a function like X86's insertDAGNode to sort newly created nodes. To avoid introducing such a function on RISC-V, we can directly emit the IMPLICIT_DEF node that UNDEF would get selected to.
1 parent e3087c4 commit 65eb468

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,8 +2104,9 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
21042104
if (IsStrided && !Subtarget->hasOptimizedZeroStrideLoad())
21052105
break;
21062106

2107-
SmallVector<SDValue> Operands =
2108-
{CurDAG->getUNDEF(VT), Ld->getBasePtr()};
2107+
SmallVector<SDValue> Operands = {
2108+
SDValue(CurDAG->getMachineNode(TargetOpcode::IMPLICIT_DEF, DL, VT), 0),
2109+
Ld->getBasePtr()};
21092110
if (IsStrided)
21102111
Operands.push_back(CurDAG->getRegister(RISCV::X0, XLenVT));
21112112
uint64_t Policy = RISCVII::MASK_AGNOSTIC | RISCVII::TAIL_AGNOSTIC;

0 commit comments

Comments
 (0)