From: Aditya Nandakumar Date: Fri, 19 Oct 2018 20:11:52 +0000 (+0000) Subject: [GISel]: Allow PHIs to be DCEd X-Git-Tag: llvmorg-8.0.0-rc1~6244 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd04e366d76c2ea0e30b71c08f4f1a374328e10a;p=platform%2Fupstream%2Fllvm.git [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 llvm-svn: 344811 --- diff --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp index 1a5f887..4d3a375 100644 --- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp +++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp @@ -137,7 +137,7 @@ bool llvm::isTriviallyDead(const MachineInstr &MI, // 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. diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir index 7c4bbfc..d8f2542 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir @@ -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