[PATCH] D53304: [GISel]: Allow Unused G_PHIs to be DCEd

Aditya Nandakumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 15 16:14:45 PDT 2018


aditya_nandakumar created this revision.
aditya_nandakumar added reviewers: ab, aemerson, bogner, rtereshin, dsanders, qcolombet, volkan.
Herald added a reviewer: javed.absar.

currently G_PHIs which are not used are still not cleaned up by DCE (as it's currently not considered safe to move). This patch changes that for G_PHI (not the PHI instruction).


Repository:
  rL LLVM

https://reviews.llvm.org/D53304

Files:
  lib/CodeGen/GlobalISel/Utils.cpp
  test/CodeGen/AArch64/GlobalISel/legalize-phi.mir


Index: test/CodeGen/AArch64/GlobalISel/legalize-phi.mir
===================================================================
--- test/CodeGen/AArch64/GlobalISel/legalize-phi.mir
+++ test/CodeGen/AArch64/GlobalISel/legalize-phi.mir
@@ -121,6 +121,7 @@
 
   bb.3:
     %9(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
+    %11:_(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
     %10(s32) = G_ZEXT %9(s1)
     $w0 = COPY %10(s32)
     RET_ReallyLR implicit $w0
Index: lib/CodeGen/GlobalISel/Utils.cpp
===================================================================
--- lib/CodeGen/GlobalISel/Utils.cpp
+++ lib/CodeGen/GlobalISel/Utils.cpp
@@ -137,7 +137,8 @@
   // If we can move an instruction, we can remove it.  Otherwise, it has
   // a side-effect of some sort.
   bool SawStore = false;
-  if (!MI.isSafeToMove(/*AA=*/nullptr, SawStore))
+  if (!MI.isSafeToMove(/*AA=*/nullptr, SawStore) &&
+      MI.getOpcode() != TargetOpcode::G_PHI)
     return false;
 
   // Instructions without side-effects are dead iff they only define dead vregs.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53304.169769.patch
Type: text/x-patch
Size: 1037 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181015/9c5a3a66/attachment.bin>


More information about the llvm-commits mailing list