ac2d5657a6 
								
							 
						 
						
							
							
								
								Fix build.  
							
							... 
							
							
							
							llvm-svn: 128733 
							
						 
						
							2011-04-01 20:15:16 +00:00  
				
					
						
							
							
								 
						
							
								d121765e64 
								
							 
						 
						
							
							
								
								InstCombine: Turn icmp + sext into bitwise/integer ops when the input has only one unknown bit.  
							
							... 
							
							
							
							int test1(unsigned x) { return (x&8) ? 0 : -1; }
int test3(unsigned x) { return (x&8) ? -1 : 0; }
before (x86_64):
_test1:
	andl	$8, %edi
	cmpl	$1, %edi
	sbbl	%eax, %eax
	ret
_test3:
	andl	$8, %edi
	cmpl	$1, %edi
	sbbl	%eax, %eax
	notl	%eax
	ret
after:
_test1:
	shrl	$3, %edi
	andl	$1, %edi
	leal	-1(%rdi), %eax
	ret
_test3:
	shll	$28, %edi
	movl	%edi, %eax
	sarl	$31, %eax
	ret
llvm-svn: 128732 
							
						 
						
							2011-04-01 20:09:10 +00:00  
				
					
						
							
							
								 
						
							
								398b8c5faf 
								
							 
						 
						
							
							
								
								InstCombine: Move (sext icmp) transforms into their own method. No intended functionality change.  
							
							... 
							
							
							
							llvm-svn: 128731 
							
						 
						
							2011-04-01 20:09:03 +00:00  
				
					
						
							
							
								 
						
							
								d74b72b8a9 
								
							 
						 
						
							
							
								
								Instcombile optimization: extractelement(cast) -> cast(extractelement)  
							
							... 
							
							
							
							llvm-svn: 128683 
							
						 
						
							2011-03-31 22:57:29 +00:00  
				
					
						
							
							
								 
						
							
								5291054ef1 
								
							 
						 
						
							
							
								
								InstCombine: APFloat can't perform arithmetic on PPC double doubles, don't even try.  
							
							... 
							
							
							
							Thanks Eli!
llvm-svn: 128676 
							
						 
						
							2011-03-31 21:35:49 +00:00  
				
					
						
							
							
								 
						
							
								be209ab8a2 
								
							 
						 
						
							
							
								
								InstCombine: Fix transform to use the swapped predicate.  
							
							... 
							
							
							
							Thanks Frits!
llvm-svn: 128628 
							
						 
						
							2011-03-31 10:46:03 +00:00  
				
					
						
							
							
								 
						
							
								d159d94644 
								
							 
						 
						
							
							
								
								InstCombine: fold fcmp (fneg x), (fneg y) -> fcmp x, y  
							
							... 
							
							
							
							llvm-svn: 128627 
							
						 
						
							2011-03-31 10:12:22 +00:00  
				
					
						
							
							
								 
						
							
								a8c5d0872d 
								
							 
						 
						
							
							
								
								InstCombine: fold fcmp pred (fneg x), C -> fcmp swap(pred) x, -C  
							
							... 
							
							
							
							llvm-svn: 128626 
							
						 
						
							2011-03-31 10:12:15 +00:00  
				
					
						
							
							
								 
						
							
								cbb18e91a8 
								
							 
						 
						
							
							
								
								InstCombine: Shrink "fcmp (fpext x), C" to "fcmp x, C" if C can be losslessly converted to the type of x.  
							
							... 
							
							
							
							Fixes PR9592.
llvm-svn: 128625 
							
						 
						
							2011-03-31 10:12:07 +00:00  
				
					
						
							
							
								 
						
							
								2ccfbc8b71 
								
							 
						 
						
							
							
								
								InstCombine: fold fcmp (fpext x), (fpext y) -> fcmp x, y.  
							
							... 
							
							
							
							llvm-svn: 128624 
							
						 
						
							2011-03-31 10:11:58 +00:00  
				
					
						
							
							
								 
						
							
								5034159c5f 
								
							 
						 
						
							
							
								
								* The DSE code that tested for overlapping needed to take into account the fact  
							
							... 
							
							
							
							that one of the numbers is signed while the other is unsigned. This could lead
  to a wrong result when the signed was promoted to an unsigned int.
* Add the data layout line to the testcase so that it will test the appropriate
  thing.
Patch by David Terei!
llvm-svn: 128577 
							
						 
						
							2011-03-30 21:37:19 +00:00  
				
					
						
							
							
								 
						
							
								8564e0de96 
								
							 
						 
						
							
							
								
								InstCombine: If the divisor of an fdiv has an exact inverse, turn it into an fmul.  
							
							... 
							
							
							
							Fixes PR9587.
llvm-svn: 128546 
							
						 
						
							2011-03-30 15:42:35 +00:00  
				
					
						
							
							
								 
						
							
								52131344a2 
								
							 
						 
						
							
							
								
								Remove PHINode::reserveOperandSpace(). Instead, add a parameter to  
							
							... 
							
							
							
							PHINode::Create() giving the (known or expected) number of operands.
llvm-svn: 128537 
							
						 
						
							2011-03-30 11:28:46 +00:00  
				
					
						
							
							
								 
						
							
								e0938d8a87 
								
							 
						 
						
							
							
								
								(Almost) always call reserveOperandSpace() on newly created PHINodes.  
							
							... 
							
							
							
							llvm-svn: 128535 
							
						 
						
							2011-03-30 11:19:20 +00:00  
				
					
						
							
							
								 
						
							
								272f2b0044 
								
							 
						 
						
							
							
								
								InstCombine: Add a few missing combines for ANDs and ORs of sign bit tests.  
							
							... 
							
							
							
							On x86 we now compile "if (a < 0 && b < 0)" into
	testl	%edi, %esi
	js	IF.THEN
llvm-svn: 128496 
							
						 
						
							2011-03-29 22:06:41 +00:00  
				
					
						
							
							
								 
						
							
								e41395ac24 
								
							 
						 
						
							
							
								
								DSE: Remove an early exit optimization that depended on the ordering of a SmallPtrSet.  
							
							... 
							
							
							
							Fixes PR9569 and will hopefully make selfhost on ASLR-enabled systems more deterministic.
llvm-svn: 128482 
							
						 
						
							2011-03-29 20:28:57 +00:00  
				
					
						
							
							
								 
						
							
								ff811cc475 
								
							 
						 
						
							
							
								
								Do some simple copy propagation through integer loads and stores when promoting  
							
							... 
							
							
							
							vector types. This helps a lot with inlined functions when using the ARM soft
float ABI. Fixes <rdar://problem/9184212>.
llvm-svn: 128453 
							
						 
						
							2011-03-29 05:19:52 +00:00  
				
					
						
							
							
								 
						
							
								ebc2f3a68c 
								
							 
						 
						
							
							
								
								Remove tabs I accidentally added.  
							
							... 
							
							
							
							llvm-svn: 128413 
							
						 
						
							2011-03-28 17:48:26 +00:00  
				
					
						
							
							
								 
						
							
								1c83965f5a 
								
							 
						 
						
							
							
								
								Make more use of PHINode::getNumIncomingValues().  
							
							... 
							
							
							
							llvm-svn: 128406 
							
						 
						
							2011-03-28 13:03:10 +00:00  
				
					
						
							
							
								 
						
							
								d14d991bf7 
								
							 
						 
						
							
							
								
								Add some debug output when -instcombine uses RAUW. This can make debug output for those cases much clearer since without this it only showed that the original instruction was removed, not what it was replaced with.  
							
							... 
							
							
							
							llvm-svn: 128399 
							
						 
						
							2011-03-27 23:32:31 +00:00  
				
					
						
							
							
								 
						
							
								8544228d5a 
								
							 
						 
						
							
							
								
								Teach the transformation that moves binary operators around selects to preserve  
							
							... 
							
							
							
							the subclass optional data.
llvm-svn: 128388 
							
						 
						
							2011-03-27 19:51:23 +00:00  
				
					
						
							
							
								 
						
							
								1f90da127f 
								
							 
						 
						
							
							
								
								Use APInt's umul_ov instead of rolling our own overflow detection.  
							
							... 
							
							
							
							llvm-svn: 128380 
							
						 
						
							2011-03-27 15:04:38 +00:00  
				
					
						
							
							
								 
						
							
								83167df787 
								
							 
						 
						
							
							
								
								Add a small missed optimization: turn X == C ? X : Y into X == C ? C : Y. This  
							
							... 
							
							
							
							removes one use of X which helps it pass the many hasOneUse() checks.
In my analysis, this turns up very often where X = A >>exact B and that can't be
simplified unless X has one use (except by increasing the lifetime of A which is
generally a performance loss).
llvm-svn: 128373 
							
						 
						
							2011-03-27 07:30:57 +00:00  
				
					
						
							
							
								 
						
							
								b5139920d6 
								
							 
						 
						
							
							
								
								Simplification noticed by Frits.  
							
							... 
							
							
							
							llvm-svn: 128333 
							
						 
						
							2011-03-26 09:32:07 +00:00  
				
					
						
							
							
								 
						
							
								19f33b9393 
								
							 
						 
						
							
							
								
								Rework the logic that determines if a store completely overlaps an ealier store.  
							
							... 
							
							
							
							There are two ways that a later store can comletely overlap a previous store:
1. They both start at the same offset, but the earlier store's size is <= the
   later's size, or
2. The earlier store's offset is > the later's offset, but it's offset + size
   doesn't extend past the later's offset + size.
llvm-svn: 128332 
							
						 
						
							2011-03-26 08:02:59 +00:00  
				
					
						
							
							
								 
						
							
								d4174ee43e 
								
							 
						 
						
							
							
								
								Fix a typo and add a test.  
							
							... 
							
							
							
							llvm-svn: 128331 
							
						 
						
							2011-03-26 04:58:50 +00:00  
				
					
						
							
							
								 
						
							
								db40b5c899 
								
							 
						 
						
							
							
								
								PR9561: A store with a negative offset (via GEP) could erroniously say that it  
							
							... 
							
							
							
							completely overlaps a previous store, thus mistakenly deleting that store. Check
for this condition.
llvm-svn: 128319 
							
						 
						
							2011-03-26 01:20:37 +00:00  
				
					
						
							
							
								 
						
							
								0e25c8b364 
								
							 
						 
						
							
							
								
								No functionality change, just adjust some whitespace for coding style compliance.  
							
							... 
							
							
							
							llvm-svn: 128257 
							
						 
						
							2011-03-25 06:05:50 +00:00  
				
					
						
							
							
								 
						
							
								74157ab3e5 
								
							 
						 
						
							
							
								
								Debug intrinsics must be skipped at the beginning and ends of blocks, lest they  
							
							... 
							
							
							
							affect the generated code.
llvm-svn: 128217 
							
						 
						
							2011-03-24 16:34:59 +00:00  
				
					
						
							
							
								 
						
							
								2edfe778ec 
								
							 
						 
						
							
							
								
								It is enough for the CallInst to have no uses to be made a tail call with a ret  
							
							... 
							
							
							
							void; it doesn't need to have a void type.
llvm-svn: 128212 
							
						 
						
							2011-03-24 15:54:11 +00:00  
				
					
						
							
							
								 
						
							
								8f606d7b9b 
								
							 
						 
						
							
							
								
								s/UpdateDT/ModifiedDT/g  
							
							... 
							
							
							
							llvm-svn: 128211 
							
						 
						
							2011-03-24 15:35:25 +00:00  
				
					
						
							
							
								 
						
							
								4649f17db1 
								
							 
						 
						
							
							
								
								Do early taildup of ret in CodeGenPrepare for potential tail calls that have a  
							
							... 
							
							
							
							void return type. This fixes PR9487.
llvm-svn: 128197 
							
						 
						
							2011-03-24 04:52:10 +00:00  
				
					
						
							
							
								 
						
							
								0e331c05ae 
								
							 
						 
						
							
							
								
								Use an early return instead of a long if block.  
							
							... 
							
							
							
							llvm-svn: 128196 
							
						 
						
							2011-03-24 04:52:07 +00:00  
				
					
						
							
							
								 
						
							
								dd84bcce8f 
								
							 
						 
						
							
							
								
								When UpdateDT is set, DT is invalid, which could cause problems when trying to  
							
							... 
							
							
							
							use it later. I couldn't make a test that hits this with the current code.
llvm-svn: 128195 
							
						 
						
							2011-03-24 04:52:04 +00:00  
				
					
						
							
							
								 
						
							
								47e7175fe9 
								
							 
						 
						
							
							
								
								Check for TLI so that -codegenprepare can be used from opt.  
							
							... 
							
							
							
							llvm-svn: 128194 
							
						 
						
							2011-03-24 04:51:51 +00:00  
				
					
						
							
							
								 
						
							
								10ebc189ee 
								
							 
						 
						
							
							
								
								Fix PR9464 by correcting some math that just happened to be right in most cases  
							
							... 
							
							
							
							that were hit in practice.
llvm-svn: 128146 
							
						 
						
							2011-03-23 05:25:55 +00:00  
				
					
						
							
							
								 
						
							
								1cc8073bb3 
								
							 
						 
						
							
							
								
								Handle another case that Frits suggested.  
							
							... 
							
							
							
							llvm-svn: 128068 
							
						 
						
							2011-03-22 03:21:01 +00:00  
				
					
						
							
							
								 
						
							
								17bbd7f495 
								
							 
						 
						
							
							
								
								Simplify.  
							
							... 
							
							
							
							llvm-svn: 128030 
							
						 
						
							2011-03-21 22:04:45 +00:00  
				
					
						
							
							
								 
						
							
								4dd420f193 
								
							 
						 
						
							
							
								
								More cleanups to the OptimizeEmptyGlobalCXXDtors GlobalOpt function.  
							
							... 
							
							
							
							llvm-svn: 127997 
							
						 
						
							2011-03-21 14:54:40 +00:00  
				
					
						
							
							
								 
						
							
								701822a48e 
								
							 
						 
						
							
							
								
								As suggested by Nick Lewycky, ignore debugging intrinsics when trying to decide whether a destructor is empty or not.  
							
							... 
							
							
							
							llvm-svn: 127985 
							
						 
						
							2011-03-21 02:42:27 +00:00  
				
					
						
							
							
								 
						
							
								d078183725 
								
							 
						 
						
							
							
								
								Fix comments  
							
							... 
							
							
							
							llvm-svn: 127984 
							
						 
						
							2011-03-21 02:26:01 +00:00  
				
					
						
							
							
								 
						
							
								0663f23bd8 
								
							 
						 
						
							
							
								
								Re-apply r127953 with fixes: eliminate empty return block if it has no predecessors; update dominator tree if cfg is modified.  
							
							... 
							
							
							
							llvm-svn: 127981 
							
						 
						
							2011-03-21 01:19:09 +00:00  
				
					
						
							
							
								 
						
							
								336fd90f4d 
								
							 
						 
						
							
							
								
								Don't try to eliminate invokes to __cxa_atexit.  
							
							... 
							
							
							
							llvm-svn: 127976 
							
						 
						
							2011-03-20 20:21:33 +00:00  
				
					
						
							
							
								 
						
							
								fcec2f519a 
								
							 
						 
						
							
							
								
								Don't segfault on mutual recursion, as pointed out by Frits.  
							
							... 
							
							
							
							llvm-svn: 127975 
							
						 
						
							2011-03-20 20:16:43 +00:00  
				
					
						
							
							
								 
						
							
								48a44911d3 
								
							 
						 
						
							
							
								
								Address comments from Frits van Bommel.  
							
							... 
							
							
							
							llvm-svn: 127974 
							
						 
						
							2011-03-20 19:51:13 +00:00  
				
					
						
							
							
								 
						
							
								ee6bc70d2f 
								
							 
						 
						
							
							
								
								Add an optimization to GlobalOpt that eliminates calls to __cxa_atexit, if the function passed is empty.  
							
							... 
							
							
							
							llvm-svn: 127970 
							
						 
						
							2011-03-20 17:59:11 +00:00  
				
					
						
							
							
								 
						
							
								327cd36f74 
								
							 
						 
						
							
							
								
								Revert r127953, "SimplifyCFG has stopped duplicating returns into predecessors  
							
							... 
							
							
							
							to canonicalize IR", it broke a lot of things.
llvm-svn: 127954 
							
						 
						
							2011-03-19 21:47:14 +00:00  
				
					
						
							
							
								 
						
							
								824a711305 
								
							 
						 
						
							
							
								
								SimplifyCFG has stopped duplicating returns into predecessors to canonicalize IR  
							
							... 
							
							
							
							to have single return block (at least getting there) for optimizations. This
is general goodness but it would prevent some tailcall optimizations.
One specific case is code like this:
int f1(void);
int f2(void);
int f3(void);
int f4(void);
int f5(void);
int f6(void);
int foo(int x) {
  switch(x) {
  case 1: return f1();
  case 2: return f2();
  case 3: return f3();
  case 4: return f4();
  case 5: return f5();
  case 6: return f6();
  }
}
=>
LBB0_2:                                 ## %sw.bb
  callq   _f1
  popq    %rbp
  ret
LBB0_3:                                 ## %sw.bb1
  callq   _f2
  popq    %rbp
  ret
LBB0_4:                                 ## %sw.bb3
  callq   _f3
  popq    %rbp
  ret
This patch teaches codegenprep to duplicate returns when the return value
is a phi and where the phi operands are produced by tail calls followed by
an unconditional branch:
sw.bb7:                                           ; preds = %entry
  %call8 = tail call i32 @f5() nounwind
  br label %return
sw.bb9:                                           ; preds = %entry
  %call10 = tail call i32 @f6() nounwind
  br label %return
return:
  %retval.0 = phi i32 [ %call10, %sw.bb9 ], [ %call8, %sw.bb7 ], ... [ 0, %entry ]
  ret i32 %retval.0
This allows codegen to generate better code like this:
LBB0_2:                                 ## %sw.bb
        jmp     _f1                     ## TAILCALL
LBB0_3:                                 ## %sw.bb1
        jmp     _f2                     ## TAILCALL
LBB0_4:                                 ## %sw.bb3
        jmp     _f3                     ## TAILCALL
rdar://9147433
llvm-svn: 127953 
							
						 
						
							2011-03-19 17:17:39 +00:00  
				
					
						
							
							
								 
						
							
								2c7ee2700c 
								
							 
						 
						
							
							
								
								If an AllocaInst referred by DbgDeclareInst is used by a LoadInst then the LoadInst should also get a corresponding llvm.dbg.value intrinsic.  
							
							... 
							
							
							
							llvm-svn: 127924 
							
						 
						
							2011-03-18 23:45:43 +00:00  
				
					
						
							
							
								 
						
							
								3ac171d49a 
								
							 
						 
						
							
							
								
								Remove dead code.  
							
							... 
							
							
							
							llvm-svn: 127923 
							
						 
						
							2011-03-18 23:33:58 +00:00