diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h --- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h +++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h @@ -185,7 +185,7 @@ private: bool doPeepholeSExtW(SDNode *Node); - bool doPeepholeMaskedRVV(SDNode *Node); + bool doPeepholeMaskedRVV(MachineSDNode *Node); bool doPeepholeMergeVVMFold(); bool performVMergeToVMv(SDNode *N); bool performCombineVMergeAndVOps(SDNode *N); diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp --- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp @@ -142,7 +142,7 @@ continue; MadeChange |= doPeepholeSExtW(N); - MadeChange |= doPeepholeMaskedRVV(N); + MadeChange |= doPeepholeMaskedRVV(cast(N)); } CurDAG->setRoot(Dummy.getValue()); @@ -3205,7 +3205,7 @@ // corresponding "unmasked" pseudo versions. The mask we're interested in will // take the form of a V0 physical register operand, with a glued // register-setting instruction. -bool RISCVDAGToDAGISel::doPeepholeMaskedRVV(SDNode *N) { +bool RISCVDAGToDAGISel::doPeepholeMaskedRVV(MachineSDNode *N) { const RISCV::RISCVMaskedPseudoInfo *I = RISCV::getMaskedPseudoInfo(N->getMachineOpcode()); if (!I) @@ -3244,7 +3244,12 @@ if (auto *TGlued = Glued->getGluedNode()) Ops.push_back(SDValue(TGlued, TGlued->getNumValues() - 1)); - SDNode *Result = CurDAG->getMachineNode(Opc, SDLoc(N), N->getVTList(), Ops); + MachineSDNode *Result = + CurDAG->getMachineNode(Opc, SDLoc(N), N->getVTList(), Ops); + + if (!N->memoperands_empty()) + CurDAG->setNodeMemRefs(Result, N->memoperands()); + Result->setFlags(N->getFlags()); ReplaceUses(N, Result); @@ -3514,10 +3519,13 @@ // Add the glue for the CopyToReg of mask->v0. Ops.push_back(Glue); - SDNode *Result = + MachineSDNode *Result = CurDAG->getMachineNode(MaskedOpc, DL, True->getVTList(), Ops); Result->setFlags(True->getFlags()); + if (!cast(True)->memoperands_empty()) + CurDAG->setNodeMemRefs(Result, cast(True)->memoperands()); + // Replace vmerge.vvm node by Result. ReplaceUses(SDValue(N, 0), SDValue(Result, 0));