[llvm] r344811 - [GISel]: Allow PHIs to be DCEd

Aditya Nandakumar via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 19 13:11:52 PDT 2018


Author: aditya_nandakumar
Date: Fri Oct 19 13:11:52 2018
New Revision: 344811

URL: http://llvm.org/viewvc/llvm-project?rev=344811&view=rev
Log:
[GISel]: Allow PHIs to be DCEd

https://reviews.llvm.org/D53304

Currently dead phis are not cleaned up during DCE. This patch allows
dead PHI and G_PHI insts to be deleted.

Reviewed by: dsanders

Modified:
    llvm/trunk/lib/CodeGen/GlobalISel/Utils.cpp
    llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir

Modified: llvm/trunk/lib/CodeGen/GlobalISel/Utils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/Utils.cpp?rev=344811&r1=344810&r2=344811&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/Utils.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/Utils.cpp Fri Oct 19 13:11:52 2018
@@ -137,7 +137,7 @@ bool llvm::isTriviallyDead(const Machine
   // 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.isPHI())
     return false;
 
   // Instructions without side-effects are dead iff they only define dead vregs.

Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir?rev=344811&r1=344810&r2=344811&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir Fri Oct 19 13:11:52 2018
@@ -121,6 +121,7 @@ body:             |
 
   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




More information about the llvm-commits mailing list