[PATCH] D106250: [NFC][LoopUtils] Use RewritePhi::ExpansionPoint for Inst to be replaced.

Hsiangkai Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 18 21:27:17 PDT 2021


HsiangKai created this revision.
HsiangKai added a reviewer: craig.topper.
Herald added subscribers: StephenFan, hiraditya.
HsiangKai requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The instruction to be replaced is recorded in RewritePhi::ExpansionPoint
when collecting RewritePhiSet. We could use the field directly. Besides
this, move Inst closer to its usage.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106250

Files:
  llvm/lib/Transforms/Utils/LoopUtils.cpp


Index: llvm/lib/Transforms/Utils/LoopUtils.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -1392,11 +1392,11 @@
     }
 
     NumReplaced++;
-    Instruction *Inst = cast<Instruction>(PN->getIncomingValue(Phi.Ith));
     PN->setIncomingValue(Phi.Ith, ExitVal);
 
     // If this instruction is dead now, delete it. Don't do it now to avoid
     // invalidating iterators.
+    Instruction *Inst = Phi.ExpansionPoint;
     if (isInstructionTriviallyDead(Inst, TLI))
       DeadInsts.push_back(Inst);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106250.359665.patch
Type: text/x-patch
Size: 616 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210719/05c67df1/attachment.bin>


More information about the llvm-commits mailing list