[PATCH] D46411: [MachineCSE] Rewrite a loop checking if a block is in a set of blocks without using a set. NFC.

Michael Zolotukhin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 3 18:44:43 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL331502: [MachineCSE] Rewrite a loop checking if a block is in a set of blocks without… (authored by mzolotukhin, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46411?vs=145116&id=145129#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46411

Files:
  llvm/trunk/lib/CodeGen/MachineCSE.cpp


Index: llvm/trunk/lib/CodeGen/MachineCSE.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/MachineCSE.cpp
+++ llvm/trunk/lib/CodeGen/MachineCSE.cpp
@@ -445,15 +445,13 @@
   // Heuristics #3: If the common subexpression is used by PHIs, do not reuse
   // it unless the defined value is already used in the BB of the new use.
   bool HasPHI = false;
-  SmallPtrSet<MachineBasicBlock*, 4> CSBBs;
-  for (MachineInstr &MI : MRI->use_nodbg_instructions(CSReg)) {
-    HasPHI |= MI.isPHI();
-    CSBBs.insert(MI.getParent());
+  for (MachineInstr &UseMI : MRI->use_nodbg_instructions(CSReg)) {
+    HasPHI |= UseMI.isPHI();
+    if (UseMI.getParent() == MI->getParent())
+      return true;
   }
 
-  if (!HasPHI)
-    return true;
-  return CSBBs.count(MI->getParent());
+  return !HasPHI;
 }
 
 void MachineCSE::EnterScope(MachineBasicBlock *MBB) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46411.145129.patch
Type: text/x-patch
Size: 895 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180504/12d8f5db/attachment.bin>


More information about the llvm-commits mailing list