[llvm-commits] [llvm] r44785 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp test/CodeGen/X86/2007-06-14-branchfold.ll

Christopher Lamb christopher.lamb at gmail.com
Sun Dec 9 23:24:07 PST 2007


Author: clamb
Date: Mon Dec 10 01:24:06 2007
New Revision: 44785

URL: http://llvm.org/viewvc/llvm-project?rev=44785&view=rev
Log:
Improve branch folding by recgonizing that explict successor relationships impact the value of fall-through choices.

Modified:
    llvm/trunk/lib/CodeGen/BranchFolding.cpp
    llvm/trunk/test/CodeGen/X86/2007-06-14-branchfold.ll

Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=44785&r1=44784&r2=44785&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original)
+++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Mon Dec 10 01:24:06 2007
@@ -775,6 +775,11 @@
   // optimize branches that branch to either a return block or an assert block
   // into a fallthrough to the return.
   if (MBB1->empty() || MBB2->empty()) return false;
+ 
+  // If there is a clear successor ordering we make sure that one block
+  // will fall through to the next
+  if (MBB1->isSuccessor(MBB2)) return true;
+  if (MBB2->isSuccessor(MBB1)) return false;
 
   MachineInstr *MBB1I = --MBB1->end();
   MachineInstr *MBB2I = --MBB2->end();

Modified: llvm/trunk/test/CodeGen/X86/2007-06-14-branchfold.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-06-14-branchfold.ll?rev=44785&r1=44784&r2=44785&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/2007-06-14-branchfold.ll (original)
+++ llvm/trunk/test/CodeGen/X86/2007-06-14-branchfold.ll Mon Dec 10 01:24:06 2007
@@ -1,7 +1,5 @@
-; RUN: llvm-as < %s | llc -mcpu=i686 | grep jmp | count 1
+; RUN: llvm-as < %s | llc -mcpu=i686 | not grep jmp
 ; check that branch folding understands FP_REG_KILL is not a branch
-; the remaining jmp can be removed if we take advantage of knowing
-; abort does not return
 
 ; ModuleID = 'g.bc'
 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"





More information about the llvm-commits mailing list