Commit Graph

5653 Commits

Author SHA1 Message Date
Dan Gohman 62995c71a2 Fix SimplifyLibCalls to transfer attributes from callees rather than
calls, since direct calls don't always reflect the attributes of their
callees.

llvm-svn: 82867
2009-09-26 18:10:13 +00:00
Dan Gohman 394468dc8e Rename ConstantFP's getInf to getInfinity.
llvm-svn: 82823
2009-09-25 23:40:21 +00:00
Dan Gohman 5ffd53892d Transform pow(x, 0.5) to (x == -inf ? inf : fabs(sqrt(x))), which is
typically faster then doing a general pow.

llvm-svn: 82819
2009-09-25 23:10:17 +00:00
Torok Edwin 21bd8c9fc5 Constant propagating byval pointer is safe if function is readonly.
llvm-svn: 82700
2009-09-24 18:33:42 +00:00
Torok Edwin f95a450ef9 Don't constant propagate byval pointers, since they are not really pointers, but
rather structs passed by value.
This fixes PR5038.

llvm-svn: 82689
2009-09-24 09:47:18 +00:00
Dale Johannesen fb1b55bc9c A minor improvment in accuracy to inline cost
computation, and some cosmetics.

llvm-svn: 82660
2009-09-23 22:05:24 +00:00
Chris Lattner e3ce1e2a37 tidy up
llvm-svn: 82488
2009-09-21 22:26:02 +00:00
Chris Lattner 247053867e big endian systems shift by bits too, hopefully this will fix the ppc
bootstrap problems.

llvm-svn: 82464
2009-09-21 17:55:47 +00:00
Dan Gohman 43d6830ea0 Nick pointed out that DominanceFrontier and DominanceTree are preserved
by setPreservesCFG().

llvm-svn: 82463
2009-09-21 17:54:42 +00:00
Dan Gohman af57ae3da4 Remove the special-case for constants in PHI nodes; it's not really
helpful, and it didn't correctly handle the case of constants input
to PHIs for backedges.

llvm-svn: 82462
2009-09-21 17:53:35 +00:00
Chris Lattner 9045f235d2 fix PR5016, a crash I introduced in GVN handing first class
arrays and structs, which cannot be bitcast to integers.

llvm-svn: 82460
2009-09-21 17:24:04 +00:00
Chris Lattner 4d8af2f1ae enable non-local analysis and PRE of large store -> little load.
This doesn't kick in too much because of phi translation issues,
but this can be resolved in the future.

llvm-svn: 82447
2009-09-21 06:48:08 +00:00
Chris Lattner 0cdc17eb50 convert an std::pair to an explicit struct.
llvm-svn: 82446
2009-09-21 06:30:24 +00:00
Chris Lattner d28f90897a move some functions, add a comment.
llvm-svn: 82444
2009-09-21 06:24:16 +00:00
Chris Lattner 9d7fb29522 split HandleLoadFromClobberingStore in two pieces: one that does the
analysis, one that does the xform.

llvm-svn: 82443
2009-09-21 06:22:46 +00:00
Chris Lattner 0a9616d906 Improve GVN to be able to forward substitute a small load
from a piece of a large store when both are in the same block.

This allows clang to compile the testcase in PR4216 to this code:

_test_bitfield:
	movl	4(%esp), %eax
	movl	%eax, %ecx
	andl	$-65536, %ecx
	orl	$32962, %eax
	andl	$40186, %eax
	orl	%ecx, %eax
	ret

This is not ideal, but is a whole lot better than the code produced
by llvm-gcc:

_test_bitfield:
	movw	$-32574, %ax
	orw	4(%esp), %ax
	andw	$-25350, %ax
	movw	%ax, 4(%esp)
	movw	7(%esp), %cx
	shlw	$8, %cx
	movzbl	6(%esp), %edx
	orw	%cx, %dx
	movzwl	%dx, %ecx
	shll	$16, %ecx
	movzwl	%ax, %eax
	orl	%ecx, %eax
	ret

and dramatically better than that produced by gcc 4.2:

_test_bitfield:
	pushl	%ebx
	call	L3
"L00000000001$pb":
L3:
	popl	%ebx
	movl	8(%esp), %eax
	leal	0(,%eax,4), %edx
	sarb	$7, %dl
	movl	%eax, %ecx
	andl	$7168, %ecx
	andl	$-7201, %ebx
	movzbl	%dl, %edx
	andl	$1, %edx
	sall	$5, %edx
	orl	%ecx, %ebx
	orl	%edx, %ebx
	andl	$24, %eax
	andl	$-58336, %ebx
	orl	%eax, %ebx
	orl	$32962, %ebx
	movl	%ebx, %eax
	popl	%ebx
	ret

llvm-svn: 82439
2009-09-21 05:57:11 +00:00
Chris Lattner 1eefa9c427 formatting cleanups, no functionality change.
llvm-svn: 82426
2009-09-21 02:42:51 +00:00
Chris Lattner a0aa8fb6a6 Move CoerceAvailableValueToLoadType earlier in GVN.cpp. Hook it up
so that nonlocal and partially redundant loads can use it as well.
The testcase shows examples of craziness this can handle.  This triggers
*many* times in 176.gcc.

llvm-svn: 82403
2009-09-20 20:09:34 +00:00
Chris Lattner 7c62d8a1a8 change the interface to CoerceAvailableValueToLoadType to be
more generic.

llvm-svn: 82402
2009-09-20 19:31:14 +00:00
Chris Lattner 1dd48c34e5 enhance GVN to forward substitute a stored value to a load
(and load -> load) when the base pointers must alias but when
they are different types.  This occurs very very frequently in
176.gcc and other code that uses bitfields a lot.

llvm-svn: 82399
2009-09-20 19:03:47 +00:00
Daniel Dunbar 7d6781b0fe Tabs -> spaces, and remove trailing whitespace.
llvm-svn: 82355
2009-09-20 02:20:51 +00:00
Nick Lewycky 1303c0ab86 Remove the default value for ConstantStruct::get's isPacked parameter and
update the code which was broken by this.

llvm-svn: 82327
2009-09-19 20:30:26 +00:00
Victor Hernandez 5d034499ad Enhance transform passes so that they apply the same tranforms to malloc calls as to MallocInst.
Reviewed by Dan Gohman.

llvm-svn: 82300
2009-09-18 22:35:49 +00:00
Victor Hernandez 788eaabd18 Update malloc call creation code (AllocType is now the element type of the malloc, not the resulting type).
In getMallocArraySize(), fix bug in the case that array size is the product of 2 constants.

Extend isArrayMalloc() and getMallocArraySize() to handle case where malloc is used as char array.

Ensure that ArraySize in LowerAllocations::runOnBasicBlock() is correct type.

Extend Instruction::isSafeToSpeculativelyExecute() to handle malloc calls.

Add verification for malloc calls.

Reviewed by Dan Gohman.

llvm-svn: 82257
2009-09-18 19:20:02 +00:00
Daniel Dunbar 487d1c8138 Update CMake.
llvm-svn: 82097
2009-09-17 00:06:48 +00:00
Dan Gohman 0f64d71d99 Add a new pass for doing late hoisting of floating-point and vector
constants out of loops. These aren't covered by the regular LICM
pass, because in LLVM IR constants don't require separate
instructions. They're not always covered by the MachineLICM pass
either, because it doesn't know how to unfold folded constant-pool
loads. This is somewhat experimental at this point, and off by
default.

llvm-svn: 82076
2009-09-16 20:25:11 +00:00
Dan Gohman bd0050810c Change FoldPHIArgBinOpIntoPHI to decline folding if it would introduce two
phis, similar to the FoldPHIArgGEPIntoPHI change.

Also, delete some comments that don't reflect the code.

llvm-svn: 82053
2009-09-16 16:50:24 +00:00
Andreas Neustifter 41c1103273 Reapplied r81355 with the problems fixed.
(See http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090907/086737.html and
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090907/086746.html)

llvm-svn: 82039
2009-09-16 11:35:50 +00:00
Andreas Neustifter f8cb758ba8 Preserve ProfileInfo during CodeGenPrepare.
llvm-svn: 82034
2009-09-16 09:26:52 +00:00
Dan Gohman 3b7ce109ec Don't sink gep operators through phi nodes if the result would require
more than one phi, since that leads to higher register pressure on
entry to the phi. This is especially problematic when the phi is in
a loop header, as it increases register pressure throughout the loop.

llvm-svn: 81993
2009-09-16 02:01:52 +00:00
Nick Lewycky 7465cd769c Add more newlines to make up for the ones removed from the end of instructions.
llvm-svn: 81851
2009-09-15 07:08:25 +00:00
Chris Lattner e0987215f0 add a new CallGraphNode::replaceCallEdge method and use it from
argpromote to avoid invalidating an iterator.  This fixes PR4977.
All clang tests now pass with expensive checking (on my system 
at least).

llvm-svn: 81843
2009-09-15 05:40:35 +00:00
Chris Lattner e9a4992399 add newline to debug dump
llvm-svn: 81840
2009-09-15 05:14:57 +00:00
Dan Gohman f9eafce3af When extending a memset range past the front, set the alignment of the
memset region to the alignment of the new start address.

llvm-svn: 81810
2009-09-14 23:39:10 +00:00
Dan Gohman 7190d48075 Factor out the code for checking that all indices in a getelementptr are
within the notional bounds of the static type of the getelementptr (which
is not the same as "inbounds") from GlobalOpt into a utility routine,
and use it in ConstantFold.cpp to check whether there are any mis-behaved
indices.

llvm-svn: 81478
2009-09-10 23:37:55 +00:00
Nick Lewycky dddf5dcdaf Correctly handle the case where a comparison is created in one BasicBlock and
used by a terminator in another.

llvm-svn: 81437
2009-09-10 07:02:09 +00:00
Evan Cheng 1d9d4bdc99 Add malloc call utility functions. Patch by Victor Hernandez.
llvm-svn: 81426
2009-09-10 04:36:43 +00:00
Dan Gohman ec4557f324 Fix SplitCriticalEdge to properly update LCSSA form when splitting a
loop exit edge -- new PHIs may be needed not only for the additional
splits that are made to preserve LoopSimplify form, but also for the
original split. Factor out the code that inserts new PHIs so that it
can be used for both. Remove LoopRotation.cpp's code for manually
updating LCSSA form, as it is now redundant. This fixes PR4934.

llvm-svn: 81363
2009-09-09 18:18:18 +00:00
Mike Stump deaf572ca8 Reflow comment.
llvm-svn: 81361
2009-09-09 17:57:16 +00:00
Andreas Neustifter 4c0b2847ef Preserve ProfileInfo.
llvm-svn: 81360
2009-09-09 17:53:39 +00:00
Dan Gohman c56af25c01 Fix an 80-column violation.
llvm-svn: 81354
2009-09-09 17:17:19 +00:00
Chris Lattner 9ded9ac8af revert r81335, which breaks the build.
llvm-svn: 81347
2009-09-09 16:00:57 +00:00
Andreas Neustifter 0bd472dc33 Updated ProfileInfo to have clean seperation between different sentinels.
llvm-svn: 81335
2009-09-09 12:48:26 +00:00
Owen Anderson f0081db7e8 Fix PR4909, patch by Jakub Staszak.
llvm-svn: 81250
2009-09-08 19:53:15 +00:00
Chris Lattner 9ce1781ef4 remove an extremely dubious instcombine transformation of
extractelement(load).

llvm-svn: 81239
2009-09-08 18:48:01 +00:00
Dan Gohman 3ddbc242fb Re-apply r80926, with fixes: keep the domtree informed of new blocks
that get created during loop unswitching, and fix SplitBlockPredecessors'
LCSSA updating code to create new PHIs instead of trying to just move
existing ones.

Also, optimize Loop::verifyLoop, since it gets called a lot. Use
searches on a sorted list of blocks instead of calling the "contains"
function, as is done in other places in the Loop class, since "contains"
does a linear search. Also, don't call verifyLoop from LoopSimplify or
LCSSA, as the PassManager is already calling verifyLoop as part of
LoopInfo's verifyAnalysis.

llvm-svn: 81221
2009-09-08 15:45:00 +00:00
Chris Lattner d1b21c6092 remove a turd
llvm-svn: 81186
2009-09-08 03:47:41 +00:00
Chris Lattner d3210e1a20 instcombine transforms vector loads that are only used by
extractelement operations into a bitcast of the pointer,
then a gep, then a scalar load.  Disable this when the vector
only has one element, because it leads to infinite loops in
instcombine (PR4908).

This transformation seems like a really bad idea to me, as it
will likely disable CSE of vector load/stores etc and can be
better done in the code generator when profitable.  This
goes all the way back to the first days of packed types,
r25299 specifically.

I'll let those people who care about the performance of vector
code decide what to do with this.

llvm-svn: 81185
2009-09-08 03:44:51 +00:00
Chris Lattner f2ab40a46f Fix PR4882, by making MemCpyOpt not dereference removed stores to get the
context for the newly created operations.
 
Patch by Jakub Staszak!

llvm-svn: 81175
2009-09-08 00:27:14 +00:00
Dan Gohman 1b84908f92 Reappy r80998, now that the GlobalOpt bug that it exposed on MiniSAT is fixed.
llvm-svn: 81172
2009-09-07 23:54:19 +00:00