[PATCH] D119934: [RISCV][NFC] Fix a mistake in PostprocessISelDAG

Haocong Lu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 16 04:52:55 PST 2022


Luhaocong created this revision.
Luhaocong added reviewers: asb, frasercrmck, craig.topper, luismarques, HsiangKai, jrtc27, benshi001.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence, vkmr, evandro, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
Luhaocong requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD, jacquesguan, MaskRay.
Herald added a project: LLVM.

With the condition `N->use_empty()` , the root node of DAG always misses peephole optimization.
A dummy node is needed here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119934

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


Index: llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -130,6 +130,7 @@
 }
 
 void RISCVDAGToDAGISel::PostprocessISelDAG() {
+  HandleSDNode Dummy(CurDAG->getRoot());
   SelectionDAG::allnodes_iterator Position = CurDAG->allnodes_end();
 
   bool MadeChange = false;
@@ -144,6 +145,8 @@
     MadeChange |= doPeepholeMaskedRVV(N);
   }
 
+  CurDAG->setRoot(Dummy.getValue());
+
   if (MadeChange)
     CurDAG->RemoveDeadNodes();
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119934.409213.patch
Type: text/x-patch
Size: 594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220216/b7109546/attachment.bin>


More information about the llvm-commits mailing list