Chris Lattner 
							
						 
					 
					
						
						
							
						
						d8ccff0c3e 
					 
					
						
						
							
							enable branch folding with an option  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31335  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-11-01 00:38:31 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						6b0e3f8907 
					 
					
						
						
							
							Make CanFallThrough more intelligent (so it can handle blocks with (e.g.) no  
						
						... 
						
						
						
						successors), and make island block movement more general.
This compiles CodeGen/X86/2006-04-27-ISelFoldingBug.ll to:
_loadAndRLEsource_no_exit_2E_1_label_2E_0:
        subl $8, %esp
        movl %esi, 4(%esp)
        movl %ebx, (%esp)
        movl 16(%esp), %eax
        movl 12(%esp), %ecx
LBB1_3: #label.0
        movl _last, %edx
        movl %edx, %esi
        incl %esi
        movl %esi, _last
        movl %ecx, %ebx
        # TRUNCATE movb %bl, %bl
        movl _block, %esi
        movb %bl, 1(%esi,%edx)
        cmpl %eax, _last
        jge LBB1_2      #codeRepl5.exitStub
LBB1_4: #label.0
        cmpl $257, %ecx
        je LBB1_2       #codeRepl5.exitStub
LBB1_1: #label.0.no_exit.1_crit_edge.exitStub
        movl $1, %eax
        movl (%esp), %ebx
        movl 4(%esp), %esi
        addl $8, %esp
        ret
LBB1_2: #codeRepl5.exitStub
        xorl %eax, %eax
        movl (%esp), %ebx
        movl 4(%esp), %esi
        addl $8, %esp
        ret
instead of:
_loadAndRLEsource_no_exit_2E_1_label_2E_0:
        subl $8, %esp
        movl %esi, 4(%esp)
        movl %ebx, (%esp)
        movl 16(%esp), %eax
        movl 12(%esp), %ecx
        jmp LBB1_3      #label.0
LBB1_1: #label.0.no_exit.1_crit_edge.exitStub
        movl $1, %eax
        movl (%esp), %ebx
        movl 4(%esp), %esi
        addl $8, %esp
        ret
LBB1_2: #codeRepl5.exitStub
        xorl %eax, %eax
        movl (%esp), %ebx
        movl 4(%esp), %esi
        addl $8, %esp
        ret
LBB1_3: #label.0
        movl _last, %edx
        movl %edx, %esi
        incl %esi
        movl %esi, _last
        movl %ecx, %ebx
        # TRUNCATE movb %bl, %bl
        movl _block, %esi
        movb %bl, 1(%esi,%edx)
        cmpl %eax, _last
        jge LBB1_2      #codeRepl5.exitStub
LBB1_4: #label.0
        cmpl $257, %ecx
        jne LBB1_1      #label.0.no_exit.1_crit_edge.exitStub
        jmp LBB1_2      #codeRepl5.exitStub
... which is much better layout :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31282  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-29 21:05:41 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						6acfe12dd6 
					 
					
						
						
							
							Teach branch folding to fold identical jump tables together and to delete  
						
						... 
						
						
						
						jump tables that are dead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31273  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-28 18:34:47 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						cf420cca57 
					 
					
						
						
							
							improve deletion of blocks that just contain branches by knowing that  
						
						... 
						
						
						
						the pred block doesn't fall through into them if it's a jumptable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31263  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-28 17:32:47 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						c2e91e34dc 
					 
					
						
						
							
							simplify code  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31188  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-25 22:21:37 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						323ece6fcd 
					 
					
						
						
							
							turn off tail merging for now  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31180  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-25 18:08:50 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						7d09784d3f 
					 
					
						
						
							
							move single basic blocks that are neither fallen into nor fall out of into  
						
						... 
						
						
						
						a place more useful.  In particular, if we can put them in a place where code
will be able to fall into it, do so.  Otherwise, put it in a place it can fall
through into a successor.  Otherwise, if preventing a fallthrough, move to the
end of the function, out of the way.
This deletes several hundred unconditional branches from spass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31149  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-24 01:12:32 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						a4bcfe12d1 
					 
					
						
						
							
							Enable tail merging by default.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31140  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-23 22:10:12 +00:00 
						 
				 
			
				
					
						
							
							
								Jim Laskey 
							
						 
					 
					
						
						
							
						
						66ebf0973d 
					 
					
						
						
							
							More complete solution to deleting blocks and debug info.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31129  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-23 14:56:37 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						4bc135e93b 
					 
					
						
						
							
							don't break infinite loops  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31102  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-21 06:11:43 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						a2d799531a 
					 
					
						
						
							
							Use branch reversal to do stuff like this:  
						
						... 
						
						
						
						call L_strcmp$stub
        testl %eax, %eax
-       jne LBB26_208   #cond_true6020
-       jmp LBB26_227   #bb7119
+       je LBB26_227    #bb7119
 LBB26_208:     #cond_true6020
        movl $l31_str14, 4(%esp)
        testl %eax, %eax
-       jne LBB26_704   #cond_true13042
-       jmp LBB26_713   #bb13151
+       je LBB26_713    #bb13151
 LBB26_704:     #cond_true13042
        movl $_str52, 4(%esp)
        cmpl 76(%ecx), %eax
-       jge LBB26_1628  #cond_false63.i.i
-       jmp LBB26_1769  #_Z8makeGridP13mrSurfaceListidiidd.exit.i
+       jl LBB26_1769   #_Z8makeGridP13mrSurfaceListidiidd.exit.i
 LBB26_1628:    #cond_false63.i.i
        movl $0, 48964(%esp)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31100  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-21 05:54:00 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						2d47bd937c 
					 
					
						
						
							
							Transform code like:  
						
						... 
						
						
						
						jle FOO
  jmp BAR
BAR:
into:
  jle FOO
BAR:
... whoa!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31098  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-21 05:43:30 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						386e29065d 
					 
					
						
						
							
							Three changes:  
						
						... 
						
						
						
						1. Remove a bunch of ifdef'd code.
2. When a block just contains an uncond branch, change all blocks branching
   to it to jump to the destination instead.
3. If branch analysis tells us some edges in the machinecfg are not actually
   possible, remove them.
#2  triggers a suprisingly large number of times.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31094  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-21 05:08:28 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						12143054aa 
					 
					
						
						
							
							Add an experimental cross-jumping implementation.  
						
						... 
						
						
						
						This is currently disabled by default and limited in several ways, but does
have a positive effect.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31090  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-21 00:47:49 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						683747abb8 
					 
					
						
						
							
							Teach the branch folder to update debug info if it removes blocks with line  
						
						... 
						
						
						
						# notes in it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31026  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-17 23:17:27 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						ffddf6ba1c 
					 
					
						
						
							
							Enable deleting branches to successor blocks.  With the previous patches,  
						
						... 
						
						
						
						branch folding can now compile stuff like this:
void foo(int W, int X, int Y, int Z) {
  if (W & 1) {
    for (; X;--X) bar();
  } else if (W & 2) {
    for (; Y;--Y) bar();
  } else if (W & 4) {
    for (; Z;--Z) bar();
  } else if (W & 8) {
    for (; W;--W) bar();
  }
  if (W) {
    bar();
  }
}
contrived testcase where loops exits all end up merging together.  To have
the loop merges be:
...
        cmplw cr0, r30, r27
        bne cr0, LBB1_14        ;bb38
LBB1_16:        ;cond_next48.loopexit
        mr r27, r29
LBB1_20:        ;cond_next48
        cmplwi cr0, r27, 0
        beq cr0, LBB1_22        ;UnifiedReturnBlock
...
instead of:
...
        cmplw cr0, r30, r27
        bne cr0, LBB1_14        ;bb38
LBB1_16:        ;cond_next48.loopexit
        mr r27, r29
        b LBB1_20       ;cond_next48
LBB1_17:        ;cond_next48.loopexit1
        b LBB1_20       ;cond_next48
LBB1_18:        ;cond_next48.loopexit2
        b LBB1_20       ;cond_next48
LBB1_19:        ;cond_next48.loopexit3
LBB1_20:        ;cond_next48
        cmplwi cr0, r27, 0
        beq cr0, LBB1_22        ;UnifiedReturnBlock
...
This is CodeGen/PowerPC/branch-opt.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31006  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-17 18:16:40 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						c50ffcb7fc 
					 
					
						
						
							
							Reenable this pass, fixing the bugs in it.  
						
						... 
						
						
						
						It now correctly deletes unreachable blocks and blocks that are empty.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31000  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-17 17:13:52 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						8f16eb98ed 
					 
					
						
						
							
							disable this pass for now, it's causing issues  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30951  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-14 00:30:06 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						7821a8afd3 
					 
					
						
						
							
							falling off the end of a function is ok with an unreachable instruction.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30950  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-14 00:21:48 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						eb15eeec39 
					 
					
						
						
							
							disable some objectionable code, maybe we can bring this pass to life  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30939  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-10-13 20:43:10 +00:00 
						 
				 
			
				
					
						
							
							
								Misha Brukman 
							
						 
					 
					
						
						
							
						
						edf128a7fa 
					 
					
						
						
							
							Remove trailing whitespace  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21420  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2005-04-21 22:36:52 +00:00 
						 
				 
			
				
					
						
							
							
								Reid Spencer 
							
						 
					 
					
						
						
							
						
						551ccae044 
					 
					
						
						
							
							Changes For Bug 352  
						
						... 
						
						
						
						Move include/Config and include/Support into include/llvm/Config,
include/llvm/ADT and include/llvm/Support. From here on out, all LLVM
public header files must be under include/llvm/.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16137  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2004-09-01 22:55:40 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						4ae131e5da 
					 
					
						
						
							
							Dereferencing end() is bad.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15402  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2004-08-01 09:51:42 +00:00 
						 
				 
			
				
					
						
							
							
								Alkis Evlogimenos 
							
						 
					 
					
						
						
							
						
						f978a1db51 
					 
					
						
						
							
							Make OptimizeBlock take a MachineFunction::iterator instead of a  
						
						... 
						
						
						
						MachineBasicBlock* as a parameter so that nxext() and prior() helper
functions can work naturally on it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15376  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2004-07-31 19:24:41 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						7f74340733 
					 
					
						
						
							
							Next on a pointer increments the pointer, not an iterator  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15375  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2004-07-31 18:40:36 +00:00 
						 
				 
			
				
					
						
							
							
								Alkis Evlogimenos 
							
						 
					 
					
						
						
							
						
						9fd332392c 
					 
					
						
						
							
							Use next() helper to make code more readable. Use  
						
						... 
						
						
						
						MachineFunction::iterator instead of MachineBasicBlock* to avoid
dereferencing end iterators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15373  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2004-07-31 15:14:29 +00:00 
						 
				 
			
				
					
						
							
							
								Alkis Evlogimenos 
							
						 
					 
					
						
						
							
						
						dd04583781 
					 
					
						
						
							
							Use MachineFunction::iterator instead of a MachineBasicBlock* because  
						
						... 
						
						
						
						FallThrough maybe == to MF.end().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15372  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2004-07-31 15:03:52 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						21ab22e475 
					 
					
						
						
							
							Implement a simple target-independent CFG cleanup pass  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15368  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2004-07-31 10:01:27 +00:00