[PATCH] D22317: Codegen: Tail Merge: Be less aggressive with special cases.

Kyle Butt via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 13 15:18:03 PDT 2016


iteratee created this revision.
iteratee added a reviewer: davidxl.
iteratee added subscribers: echristo, llvm-commits.
iteratee set the repository for this revision to rL LLVM.

This change makes it possible for tail-duplication and tail-merging to
be disjoint.

Don't special case fallthrough if it requires replacing a conditional jump with an unconditional jump.

Repository:
  rL LLVM

http://reviews.llvm.org/D22317

Files:
  lib/CodeGen/BranchFolding.cpp
  test/CodeGen/Hexagon/rdf-copy.ll

Index: test/CodeGen/Hexagon/rdf-copy.ll
===================================================================
--- test/CodeGen/Hexagon/rdf-copy.ll
+++ test/CodeGen/Hexagon/rdf-copy.ll
@@ -17,7 +17,7 @@
 ; CHECK: [[DST:r[0-9]+]] = [[SRC:r[0-9]+]]
 ; CHECK-DAG: memw([[SRC]]
 ; CHECK-NOT: memw([[DST]]
-; CHECK-LABEL: LBB0_2
+; CHECK: %if.end
 
 target datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32-f64:64:64-f32:32:32-v64:64:64-v32:32:32-a0:0-n16:32"
 target triple = "hexagon"
Index: lib/CodeGen/BranchFolding.cpp
===================================================================
--- lib/CodeGen/BranchFolding.cpp
+++ lib/CodeGen/BranchFolding.cpp
@@ -616,8 +616,9 @@
                << '\n');
 
   // It's almost always profitable to merge any number of non-terminator
-  // instructions with the block that falls through into the common successor.
-  if (MBB1 == PredBB || MBB2 == PredBB) {
+  // instructions with the block that falls through into the common successor,
+  // when SuccBB is the only successor.
+  if ((MBB1 == PredBB || MBB2 == PredBB) && MBB1->succ_size() == 1) {
     MachineBasicBlock::iterator I;
     unsigned NumTerms = CountTerminators(MBB1 == PredBB ? MBB2 : MBB1, I);
     if (CommonTailLen > NumTerms)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22317.63866.patch
Type: text/x-patch
Size: 1252 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160713/4de43147/attachment.bin>


More information about the llvm-commits mailing list