Stephen Lin
							
						 
						
							 
							
							
							
							
								
							
							
								c1c7a1309c 
								
							 
						 
						
							
							
								
								Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change.  
							
							 
							
							... 
							
							
							
							This update was done with the following bash script:
  find test/Transforms -name "*.ll" | \
  while read NAME; do
    echo "$NAME"
    if ! grep -q "^; *RUN: *llc" $NAME; then
      TEMP=`mktemp -t temp`
      cp $NAME $TEMP
      sed -n "s/^define [^@]*@\([A-Za-z0-9_]*\)(.*$/\1/p" < $NAME | \
      while read FUNC; do
        sed -i '' "s/;\(.*\)\([A-Za-z0-9_]*\):\( *\)@$FUNC\([( ]*\)\$/;\1\2-LABEL:\3@$FUNC(/g" $TEMP
      done
      mv $TEMP $NAME
    fi
  done
llvm-svn: 186268 
							
						 
						
							2013-07-14 01:42:54 +00:00  
						
					 
				
					
						
							
							
								 
								Benjamin Kramer
							
						 
						
							 
							
							
							
							
								
							
							
								371722288c 
								
							 
						 
						
							
							
								
								SimplifyCFG: Teach switch generation some patterns that instcombine forms.  
							
							 
							
							... 
							
							
							
							This allows us to create switches even if instcombine has munged two of the
incombing compares into one and some bit twiddling. This was motivated by enum
compares that are common in clang.
llvm-svn: 185632 
							
						 
						
							2013-07-04 14:22:02 +00:00  
						
					 
				
					
						
							
							
								 
								Hans Wennborg
							
						 
						
							 
							
							
							
							
								
							
							
								c3c8d95c51 
								
							 
						 
						
							
							
								
								Only do switch-to-lookup table transformation when TargetTransformInfo  
							
							 
							
							... 
							
							
							
							is available.
llvm-svn: 167552 
							
						 
						
							2012-11-07 21:35:12 +00:00  
						
					 
				
					
						
							
							
								 
								Hans Wennborg
							
						 
						
							 
							
							
							
							
								
							
							
								8a62fc5294 
								
							 
						 
						
							
							
								
								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.
llvm-svn: 163302 
							
						 
						
							2012-09-06 09:43:28 +00:00  
						
					 
				
					
						
							
							
								 
								Eric Christopher
							
						 
						
							 
							
							
							
							
								
							
							
								b65acc61a5 
								
							 
						 
						
							
							
								
								Revert "IntRange:" as it appears to be breaking self hosting.  
							
							 
							
							... 
							
							
							
							This reverts commit b2833d9dcba88c6f0520cad760619200adc0442c.
llvm-svn: 159618 
							
						 
						
							2012-07-02 23:22:21 +00:00  
						
					 
				
					
						
							
							
								 
								Stepan Dyatkovskiy
							
						 
						
							 
							
							
							
							
								
							
							
								8b9ecca42d 
								
							 
						 
						
							
							
								
								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
llvm-svn: 159527 
							
						 
						
							2012-07-02 13:02:18 +00:00  
						
					 
				
					
						
							
							
								 
								Benjamin Kramer
							
						 
						
							 
							
							
							
							
								
							
							
								8d6a8c130b 
								
							 
						 
						
							
							
								
								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.
llvm-svn: 125056 
							
						 
						
							2011-02-07 22:37:28 +00:00  
						
					 
				
					
						
							
							
								 
								Benjamin Kramer
							
						 
						
							 
							
							
							
							
								
							
							
								f4ea1d5f79 
								
							 
						 
						
							
							
								
								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
llvm-svn: 124724 
							
						 
						
							2011-02-02 15:56:22 +00:00  
						
					 
				
					
						
							
							
								 
								Evan Cheng
							
						 
						
							 
							
							
							
							
								
							
							
								d983eba7dc 
								
							 
						 
						
							
							
								
								Re-apply r124518 with fix. Watch out for invalidated iterator.  
							
							 
							
							... 
							
							
							
							llvm-svn: 124526 
							
						 
						
							2011-01-29 04:46:23 +00:00  
						
					 
				
					
						
							
							
								 
								Evan Cheng
							
						 
						
							 
							
							
							
							
								
							
							
								65b8ccf6ac 
								
							 
						 
						
							
							
								
								Revert r124518. It broke Linux self-host.  
							
							 
							
							... 
							
							
							
							llvm-svn: 124522 
							
						 
						
							2011-01-29 02:43:04 +00:00  
						
					 
				
					
						
							
							
								 
								Evan Cheng
							
						 
						
							 
							
							
							
							
								
							
							
								d4eff31476 
								
							 
						 
						
							
							
								
								Re-commit r124462 with fixes. Tail recursion elim will now dup ret into unconditional predecessor to enable TCE on demand.  
							
							 
							
							... 
							
							
							
							llvm-svn: 124518 
							
						 
						
							2011-01-29 01:29:26 +00:00  
						
					 
				
					
						
							
							
								 
								Evan Cheng
							
						 
						
							 
							
							
							
							
								
							
							
								aaa9606b2f 
								
							 
						 
						
							
							
								
								Revert r124462. There are a few big regressions that I need to fix first.  
							
							 
							
							... 
							
							
							
							llvm-svn: 124478 
							
						 
						
							2011-01-28 07:12:38 +00:00  
						
					 
				
					
						
							
							
								 
								Evan Cheng
							
						 
						
							 
							
							
							
							
								
							
							
								417fca86c4 
								
							 
						 
						
							
							
								
								- 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.
llvm-svn: 124462 
							
						 
						
							2011-01-28 02:19:21 +00:00  
						
					 
				
					
						
							
							
								 
								Benjamin Kramer
							
						 
						
							 
							
							
							
							
								
							
							
								e5f49c4ff2 
								
							 
						 
						
							
							
								
								SimplifyCFG: Ranges can be larger than 64 bits. Fixes Release-selfhost build.  
							
							 
							
							... 
							
							
							
							llvm-svn: 122054 
							
						 
						
							2010-12-17 10:48:14 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								d14b0f1db7 
								
							 
						 
						
							
							
								
								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.
llvm-svn: 122045 
							
						 
						
							2010-12-17 06:20:15 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								7499b452c1 
								
							 
						 
						
							
							
								
								- 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.
llvm-svn: 121764 
							
						 
						
							2010-12-14 08:46:09 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								f130661688 
								
							 
						 
						
							
							
								
								fix yet anohter broken line  
							
							 
							
							... 
							
							
							
							llvm-svn: 121750 
							
						 
						
							2010-12-14 06:09:07 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								5a9d59d918 
								
							 
						 
						
							
							
								
								reapply my recent change that disables a piece of the switch formation  
							
							 
							
							... 
							
							
							
							work, but fixes 400.perlbmk.
llvm-svn: 121749 
							
						 
						
							2010-12-14 05:57:30 +00:00  
						
					 
				
					
						
							
							
								 
								Owen Anderson
							
						 
						
							 
							
							
							
							
								
							
							
								3e5648896e 
								
							 
						 
						
							
							
								
								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.
llvm-svn: 121733 
							
						 
						
							2010-12-13 23:49:28 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								a6e5d5694a 
								
							 
						 
						
							
							
								
								temporarily disable part of my previous patch, which causes an iterator invalidation issue, causing a crash on some versions of perlbmk.  
							
							 
							
							... 
							
							
							
							llvm-svn: 121728 
							
						 
						
							2010-12-13 23:02:19 +00:00  
						
					 
				
					
						
							
							
								 
								Benjamin Kramer
							
						 
						
							 
							
							
							
							
								
							
							
								1e155ab7e1 
								
							 
						 
						
							
							
								
								Fix sort predicate. qsort(3)'s predicate semantics differ from std::sort's. Fixes PR 8780.  
							
							 
							
							... 
							
							
							
							llvm-svn: 121705 
							
						 
						
							2010-12-13 18:20:38 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								fb836f8c1a 
								
							 
						 
						
							
							
								
								reinstate my patch: the miscompile was caused by an inverted branch in the  
							
							 
							
							... 
							
							
							
							'and' case.
llvm-svn: 121695 
							
						 
						
							2010-12-13 08:12:19 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								79db357d80 
								
							 
						 
						
							
							
								
								Completely disable the optimization I added in r121680 until  
							
							 
							
							... 
							
							
							
							I can track down a miscompile.  This should bring the buildbots
back to life
llvm-svn: 121693 
							
						 
						
							2010-12-13 07:41:29 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								fbeb55844b 
								
							 
						 
						
							
							
								
								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
llvm-svn: 121690 
							
						 
						
							2010-12-13 07:00:06 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								cb570f87e5 
								
							 
						 
						
							
							
								
								fix a bug in r121680 that upset the various buildbots.  
							
							 
							
							... 
							
							
							
							llvm-svn: 121687 
							
						 
						
							2010-12-13 05:34:18 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								a442f24a36 
								
							 
						 
						
							
							
								
								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.
llvm-svn: 121680 
							
						 
						
							2010-12-13 04:50:38 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								a737721d14 
								
							 
						 
						
							
							
								
								merge two tests  
							
							 
							
							... 
							
							
							
							llvm-svn: 121679 
							
						 
						
							2010-12-13 04:45:56 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								62cc76e9cc 
								
							 
						 
						
							
							
								
								Fix my previous patch to handle a degenerate case that the llvm-gcc  
							
							 
							
							... 
							
							
							
							bootstrap buildbot tripped over.
llvm-svn: 121674 
							
						 
						
							2010-12-13 03:43:57 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								d9bacc088a 
								
							 
						 
						
							
							
								
								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.
llvm-svn: 121671 
							
						 
						
							2010-12-13 03:18:54 +00:00  
						
					 
				
					
						
							
							
								 
								Chris Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								e54242dc02 
								
							 
						 
						
							
							
								
								fix a bunch of spurious failures for people whose home directory  
							
							 
							
							... 
							
							
							
							is sabre.
llvm-svn: 81528 
							
						 
						
							2009-09-11 17:02:12 +00:00  
						
					 
				
					
						
							
							
								 
								Dan Gohman
							
						 
						
							 
							
							
							
							
								
							
							
								72a13d2476 
								
							 
						 
						
							
							
								
								Use opt -S instead of piping bitcode output through llvm-dis.  
							
							 
							
							... 
							
							
							
							llvm-svn: 81257 
							
						 
						
							2009-09-08 22:34:10 +00:00  
						
					 
				
					
						
							
							
								 
								Dan Gohman
							
						 
						
							 
							
							
							
							
								
							
							
								9737a63ed8 
								
							 
						 
						
							
							
								
								Change these tests to feed the assembly files to opt directly, instead  
							
							 
							
							... 
							
							
							
							of using llvm-as, now that opt supports this.
llvm-svn: 81226 
							
						 
						
							2009-09-08 16:50:01 +00:00  
						
					 
				
					
						
							
							
								 
								Tanya Lattner
							
						 
						
							 
							
							
							
							
								
							
							
								baa370b37a 
								
							 
						 
						
							
							
								
								Upgrade tests to not use llvm-upgrade.  
							
							 
							
							... 
							
							
							
							llvm-svn: 48483 
							
						 
						
							2008-03-18 03:45:45 +00:00  
						
					 
				
					
						
							
							
								 
								Reid Spencer
							
						 
						
							 
							
							
							
							
								
							
							
								83b3d82672 
								
							 
						 
						
							
							
								
								Regression is gone, don't try to find it on clean target.  
							
							 
							
							... 
							
							
							
							llvm-svn: 33296 
							
						 
						
							2007-01-17 07:59:14 +00:00