Hans Wennborg 
							
						 
					 
					
						
						
							
						
						b0319962cf 
					 
					
						
						
							
							Only do switch-to-lookup table transformation when TargetTransformInfo  
						
						... 
						
						
						
						is available.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167552  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2012-11-07 21:35:12 +00:00 
						 
				 
			
				
					
						
							
							
								Hans Wennborg 
							
						 
					 
					
						
						
							
						
						486270aee6 
					 
					
						
						
							
							Build lookup tables for switches (PR884)  
						
						... 
						
						
						
						This adds a transformation to SimplifyCFG that attemps to turn switch
instructions into loads from lookup tables. It works on switches that
are only used to initialize one or more phi nodes in a common successor
basic block, for example:
  int f(int x) {
    switch (x) {
    case 0: return 5;
    case 1: return 4;
    case 2: return -2;
    case 5: return 7;
    case 6: return 9;
    default: return 42;
  }
This speeds up the code by removing the hard-to-predict jump, and
reduces code size by removing the code for the jump targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163302  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2012-09-06 09:43:28 +00:00 
						 
				 
			
				
					
						
							
							
								Eric Christopher 
							
						 
					 
					
						
						
							
						
						c723eb1aef 
					 
					
						
						
							
							Revert "IntRange:" as it appears to be breaking self hosting.  
						
						... 
						
						
						
						This reverts commit b2833d9dcbhttps://llvm.org/svn/llvm-project/llvm/trunk@159618  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2012-07-02 23:22:21 +00:00 
						 
				 
			
				
					
						
							
							
								Stepan Dyatkovskiy 
							
						 
					 
					
						
						
							
						
						b2833d9dcb 
					 
					
						
						
							
							IntRange:  
						
						... 
						
						
						
						- Changed isSingleNumber method behaviour. Now this flag is calculated on demand.
IntegersSubsetMapping
  - Optimized diff operation.
  - Replaced type of Items field from std::list with std::map.
  - Added new methods:
    bool isOverlapped(self &RHS)
    void add(self& RHS, SuccessorClass *S)
    void detachCase(self& NewMapping, SuccessorClass *Succ)
    void removeCase(SuccessorClass *Succ)
    SuccessorClass *findSuccessor(const IntTy& Val)
    const IntTy* getCaseSingleNumber(SuccessorClass *Succ)
IntegersSubsetTest
  - DiffTest: Added checks for successors.
SimplifyCFG
  Updated SwitchInst usage (now it is case-ragnes compatible) for
    - SimplifyEqualityComparisonWithOnlyPredecessor
    - FoldValueComparisonIntoPredecessors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159527  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2012-07-02 13:02:18 +00:00 
						 
				 
			
				
					
						
							
							
								Benjamin Kramer 
							
						 
					 
					
						
						
							
						
						33828bcb24 
					 
					
						
						
							
							SimplifyCFG: Track the number of used icmps when turning a icmp chain into a switch. If we used only one icmp, don't turn it into a switch.  
						
						... 
						
						
						
						Also prevent the switch-to-icmp transform from creating identity adds, noticed by Marius Wachtler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125056  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2011-02-07 22:37:28 +00:00 
						 
				 
			
				
					
						
							
							
								Benjamin Kramer 
							
						 
					 
					
						
						
							
						
						56442dfdcf 
					 
					
						
						
							
							SimplifyCFG: Turn switches into sub+icmp+branch if possible.  
						
						... 
						
						
						
						This makes the job of the later optzn passes easier, allowing the vast amount of
icmp transforms to chew on it.
We transform 840 switches in gcc.c, leading to a 16k byte shrink of the resulting
binary on i386-linux.
The testcase from README.txt now compiles into
  decl  %edi
  cmpl  $3, %edi
  sbbl  %eax, %eax
  andl  $1, %eax
  ret
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124724  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2011-02-02 15:56:22 +00:00 
						 
				 
			
				
					
						
							
							
								Evan Cheng 
							
						 
					 
					
						
						
							
						
						c3f507f98a 
					 
					
						
						
							
							Re-apply r124518 with fix. Watch out for invalidated iterator.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124526  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2011-01-29 04:46:23 +00:00 
						 
				 
			
				
					
						
							
							
								Evan Cheng 
							
						 
					 
					
						
						
							
						
						b0a42fdb36 
					 
					
						
						
							
							Revert r124518. It broke Linux self-host.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124522  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2011-01-29 02:43:04 +00:00 
						 
				 
			
				
					
						
							
							
								Evan Cheng 
							
						 
					 
					
						
						
							
						
						5e6940788f 
					 
					
						
						
							
							Re-commit r124462 with fixes. Tail recursion elim will now dup ret into unconditional predecessor to enable TCE on demand.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124518  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2011-01-29 01:29:26 +00:00 
						 
				 
			
				
					
						
							
							
								Evan Cheng 
							
						 
					 
					
						
						
							
						
						1b5c0cb71d 
					 
					
						
						
							
							Revert r124462. There are a few big regressions that I need to fix first.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124478  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2011-01-28 07:12:38 +00:00 
						 
				 
			
				
					
						
							
							
								Evan Cheng 
							
						 
					 
					
						
						
							
						
						40f64cb0de 
					 
					
						
						
							
							- Stop simplifycfg from duplicating "ret" instructions into unconditional  
						
						... 
						
						
						
						branches. PR8575, rdar://5134905, rdar://8911460.
- Allow codegen tail duplication to dup small return blocks after register
  allocation is done.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124462  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2011-01-28 02:19:21 +00:00 
						 
				 
			
				
					
						
							
							
								Benjamin Kramer 
							
						 
					 
					
						
						
							
						
						14c0987bd9 
					 
					
						
						
							
							SimplifyCFG: Ranges can be larger than 64 bits. Fixes Release-selfhost build.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122054  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-17 10:48:14 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						e27db74a60 
					 
					
						
						
							
							improve switch formation to handle small range  
						
						... 
						
						
						
						comparisons formed by comparisons.  For example,
this:
void foo(unsigned x) {
  if (x == 0 || x == 1 || x == 3 || x == 4 || x == 6) 
    bar();
}
compiles into:
_foo:                                   ## @foo
## BB#0:                                ## %entry
	cmpl	$6, %edi
	ja	LBB0_2
## BB#1:                                ## %entry
	movl	%edi, %eax
	movl	$91, %ecx
	btq	%rax, %rcx
	jb	LBB0_3
instead of:
_foo:                                   ## @foo
## BB#0:                                ## %entry
	cmpl	$2, %edi
	jb	LBB0_4
## BB#1:                                ## %switch.early.test
	cmpl	$6, %edi
	ja	LBB0_3
## BB#2:                                ## %switch.early.test
	movl	%edi, %eax
	movl	$88, %ecx
	btq	%rax, %rcx
	jb	LBB0_4
This catches a bunch of cases in GCC, which look like this:
 %804 = load i32* @which_alternative, align 4, !tbaa !0 
 %805 = icmp ult i32 %804, 2
 %806 = icmp eq i32 %804, 3
 %or.cond121 = or i1 %805, %806
 %807 = icmp eq i32 %804, 4
 %or.cond124 = or i1 %or.cond121, %807
 br i1 %or.cond124, label %.thread, label %808
turning this into a range comparison.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122045  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-17 06:20:15 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						3aff13b82a 
					 
					
						
						
							
							- Insert new instructions before DomBlock's terminator,  
						
						... 
						
						
						
						which is simpler than finding a place to insert in BB.
 - Don't perform the 'if condition hoisting' xform on certain
   i1 PHIs, as it interferes with switch formation.
This re-fixes "example 7", without breaking the world hopefully.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121764  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-14 08:46:09 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						8168efffa7 
					 
					
						
						
							
							fix yet anohter broken line  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121750  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-14 06:09:07 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						117f8cffc5 
					 
					
						
						
							
							reapply my recent change that disables a piece of the switch formation  
						
						... 
						
						
						
						work, but fixes 400.perlbmk.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121749  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-14 05:57:30 +00:00 
						 
				 
			
				
					
						
							
							
								Owen Anderson 
							
						 
					 
					
						
						
							
						
						2d9220e8f5 
					 
					
						
						
							
							Fix recent buildbot breakage by pulling SimplifyCFG back to its state as of r121694, the most recent state  
						
						... 
						
						
						
						where I'm confident there were no crashes or miscompilations.  XFAIL the test added since then for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121733  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-13 23:49:28 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						f9a1b2a4cf 
					 
					
						
						
							
							temporarily disable part of my previous patch, which causes an iterator invalidation issue, causing a crash on some versions of perlbmk.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121728  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-13 23:02:19 +00:00 
						 
				 
			
				
					
						
							
							
								Benjamin Kramer 
							
						 
					 
					
						
						
							
						
						cf8b3257c0 
					 
					
						
						
							
							Fix sort predicate. qsort(3)'s predicate semantics differ from std::sort's. Fixes PR 8780.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121705  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-13 18:20:38 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						a9f6bbea62 
					 
					
						
						
							
							reinstate my patch: the miscompile was caused by an inverted branch in the  
						
						... 
						
						
						
						'and' case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121695  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-13 08:12:19 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						92407e5895 
					 
					
						
						
							
							Completely disable the optimization I added in r121680 until  
						
						... 
						
						
						
						I can track down a miscompile.  This should bring the buildbots
back to life
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121693  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-13 07:41:29 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						daa02ab70c 
					 
					
						
						
							
							Make simplifycfg reprocess newly formed "br (cond1 | cond2)" conditions  
						
						... 
						
						
						
						when simplifying, allowing them to be eagerly turned into switches.  This
is the last step required to get "Example 7" from this blog post:
http://blog.regehr.org/archives/320 
On X86, we now generate this machine code, which (to my eye) seems better
than the ICC generated code:
_crud:                                  ## @crud
## BB#0:                                ## %entry
	cmpb	$33, %dil
	jb	LBB0_4
## BB#1:                                ## %switch.early.test
	addb	$-34, %dil
	cmpb	$58, %dil
	ja	LBB0_3
## BB#2:                                ## %switch.early.test
	movzbl	%dil, %eax
	movabsq	$288230376537592865, %rcx ## imm = 0x400000017001421
	btq	%rax, %rcx
	jb	LBB0_4
LBB0_3:                                 ## %lor.rhs
	xorl	%eax, %eax
	ret
LBB0_4:                                 ## %lor.end
	movl	$1, %eax
	ret
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121690  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-13 07:00:06 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						97bd89ece3 
					 
					
						
						
							
							fix a bug in r121680 that upset the various buildbots.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121687  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-13 05:34:18 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						7312a22ed6 
					 
					
						
						
							
							enhance the "change or icmp's into switch" xform to handle one value in an  
						
						... 
						
						
						
						'or sequence' that it doesn't understand.  This allows us to optimize
something insane like this:
int crud (unsigned char c, unsigned x)
 {
   if(((((((((( (int) c <= 32 ||
                    (int) c == 46) || (int) c == 44)
                  || (int) c == 58) || (int) c == 59) || (int) c == 60)
               || (int) c == 62) || (int) c == 34) || (int) c == 92)
            || (int) c == 39) != 0)
     foo();
 }
into:
define i32 @crud(i8 zeroext %c, i32 %x) nounwind ssp noredzone {
entry:
  %cmp = icmp ult i8 %c, 33
  br i1 %cmp, label %if.then, label %switch.early.test
switch.early.test:                                ; preds = %entry
  switch i8 %c, label %if.end [
    i8 39, label %if.then
    i8 44, label %if.then
    i8 58, label %if.then
    i8 59, label %if.then
    i8 60, label %if.then
    i8 62, label %if.then
    i8 46, label %if.then
    i8 92, label %if.then
    i8 34, label %if.then
  ]
by pulling the < comparison out ahead of the newly formed switch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121680  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-13 04:50:38 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						f5198e7fe3 
					 
					
						
						
							
							merge two tests  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121679  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-13 04:45:56 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						abf706703f 
					 
					
						
						
							
							Fix my previous patch to handle a degenerate case that the llvm-gcc  
						
						... 
						
						
						
						bootstrap buildbot tripped over.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121674  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-13 03:43:57 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						61c77449c7 
					 
					
						
						
							
							fix a fairly serious oversight with switch formation from  
						
						... 
						
						
						
						or'd conditions.  Previously we'd compile something like this:
int crud (unsigned char c) {
   return c == 62 || c == 34 || c == 92;
}
into:
  switch i8 %c, label %lor.rhs [
    i8 62, label %lor.end
    i8 34, label %lor.end
  ]
lor.rhs:                                          ; preds = %entry
  %cmp8 = icmp eq i8 %c, 92
  br label %lor.end
lor.end:                                          ; preds = %entry, %entry, %lor.rhs
  %0 = phi i1 [ true, %entry ], [ %cmp8, %lor.rhs ], [ true, %entry ]
  %lor.ext = zext i1 %0 to i32
  ret i32 %lor.ext
which failed to merge the compare-with-92 into the switch.  With this patch
we simplify this all the way to:
  switch i8 %c, label %lor.rhs [
    i8 62, label %lor.end
    i8 34, label %lor.end
    i8 92, label %lor.end
  ]
lor.rhs:                                          ; preds = %entry
  br label %lor.end
lor.end:                                          ; preds = %entry, %entry, %entry, %lor.rhs
  %0 = phi i1 [ true, %entry ], [ false, %lor.rhs ], [ true, %entry ], [ true, %entry ]
  %lor.ext = zext i1 %0 to i32
  ret i32 %lor.ext
which is much better for codegen's switch lowering stuff.  This kicks in 33 times
on 176.gcc (for example) cutting 103 instructions off the generated code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121671  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2010-12-13 03:18:54 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						50b957549b 
					 
					
						
						
							
							fix a bunch of spurious failures for people whose home directory  
						
						... 
						
						
						
						is sabre.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81528  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2009-09-11 17:02:12 +00:00 
						 
				 
			
				
					
						
							
							
								Dan Gohman 
							
						 
					 
					
						
						
							
						
						3e054fe9ef 
					 
					
						
						
							
							Use opt -S instead of piping bitcode output through llvm-dis.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81257  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2009-09-08 22:34:10 +00:00 
						 
				 
			
				
					
						
							
							
								Dan Gohman 
							
						 
					 
					
						
						
							
						
						b1e1e82c54 
					 
					
						
						
							
							Change these tests to feed the assembly files to opt directly, instead  
						
						... 
						
						
						
						of using llvm-as, now that opt supports this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81226  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2009-09-08 16:50:01 +00:00 
						 
				 
			
				
					
						
							
							
								Tanya Lattner 
							
						 
					 
					
						
						
							
						
						f04d8d1593 
					 
					
						
						
							
							Upgrade tests to not use llvm-upgrade.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48483  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2008-03-18 03:45:45 +00:00 
						 
				 
			
				
					
						
							
							
								Reid Spencer 
							
						 
					 
					
						
						
							
						
						69ccadd753 
					 
					
						
						
							
							Use the llvm-upgrade program to upgrade llvm assembly.  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32115  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2006-12-02 04:23:10 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						90970609f2 
					 
					
						
						
							
							add another testcase to make sure it gets turned into a switch (answer: yes it does)  
						
						... 
						
						
						
						git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20291  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2005-02-24 02:13:50 +00:00 
						 
				 
			
				
					
						
							
							
								Chris Lattner 
							
						 
					 
					
						
						
							
						
						d1eaebef49 
					 
					
						
						
							
							The simplifycfg pass should be able to turn stuff like:  
						
						... 
						
						
						
						if (X == 4 || X == 7)
and
  if (X != 4 && X != 7)
into switch instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11791  91177308-0d34-0410-b5e6-96231b3b80d8 
						
						
					 
					
						2004-02-24 05:34:44 +00:00