Commit Graph

2884 Commits

Author SHA1 Message Date
Duncan Sands
ceb4d1aecb Rename getABITypeSize to getTypePaddedSize, as
suggested by Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62099 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-12 20:38:59 +00:00
Chris Lattner
31a69cb9ae Duncan is nervous about undefinedness of % with negatives. I'm
not thrilled about 64-bit % in general, so rewrite to use * instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62047 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-11 20:41:36 +00:00
Chris Lattner
1c412d9ce4 do not generated GEPs into vectors where they don't already exist.
We should treat vectors as atomic types, not like arrays.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62046 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-11 20:23:52 +00:00
Chris Lattner
dbc3bc2585 Make a couple of cleanups to the instcombine bitcast/gep
canonicalization transform based on duncan's comments:

1) improve the comment about %.
2) within our index loop make sure the offset stays 
   within the *type size*, instead of within the *abi size*.
   This allows us to reason explicitly about landing in tail
   padding and means that issues like non-zero offsets into
   [0 x foo] types don't occur anymore.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62045 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-11 20:15:20 +00:00
Chris Lattner
ed78f431ed fix typo Duncan noticed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61997 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 18:31:39 +00:00
Chris Lattner
583dd6072e Fix PR3304
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61995 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 18:18:43 +00:00
Misha Brukman
9b8f542e27 Removed trailing whitespace from Makefiles.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61991 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 16:44:42 +00:00
Chris Lattner
a80d668215 Implement rdar://6480391, extending of equality icmp's to avoid a truncation.
I noticed this in the code compiled for a routine using std::map, which produced
this code:
	%25 = tail call i32 @memcmp(i8* %24, i8* %23, i32 6) nounwind readonly
	%.lobit.i = lshr i32 %25, 31		; <i32> [#uses=1]
	%tmp.i = trunc i32 %.lobit.i to i8		; <i8> [#uses=1]
	%toBool = icmp eq i8 %tmp.i, 0		; <i1> [#uses=1]
	br i1 %toBool, label %bb3, label %bb4
which compiled to:

	call	L_memcmp$stub
	shrl	$31, %eax
	testb	%al, %al
	jne	LBB1_11	## 

with this change, we compile it to:

	call	L_memcmp$stub
	testl	%eax, %eax
	js	LBB1_11

This triggers all the time in common code, with patters like this:

	%169 = and i32 %ply, 1		; <i32> [#uses=1]
	%170 = trunc i32 %169 to i8		; <i8> [#uses=1]
	%toBool = icmp ne i8 %170, 0		; <i1> [#uses=1]

 	%7 = lshr i32 %6, 24		; <i32> [#uses=1]
	%9 = trunc i32 %7 to i8		; <i8> [#uses=1]
	%10 = icmp ne i8 %9, 0		; <i1> [#uses=1]

etc



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61985 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 07:47:06 +00:00
Chris Lattner
6d6b410698 Remove some old code that looks like a remanant from signed-types days.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61984 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 07:10:58 +00:00
Chris Lattner
2a99b482a6 Fix PR3298, a crash in Jump Threading. Apparently even
jump threading can have bugs, who knew? ;-)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61983 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 06:08:12 +00:00
Chris Lattner
46cd5a13e5 Fix part 3/2 of PR3290, making instcombine zap (gep(bitcast)) when possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61980 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 05:44:56 +00:00
Chris Lattner
5840779cc9 move some code, check to see if the input to the GEP is a bitcast
(which is constant time and cheap) before checking hasAllZeroIndices.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61976 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 04:53:57 +00:00
Chris Lattner
5ffe6acd57 This implements the second half of the fix for PR3290, handling
loads from allocas that cover the entire aggregate.  This handles
some memcpy/byval cases that are produced by llvm-gcc.  This triggers
a few times in kc++ (with std::pair<std::_Rb_tree_const_iterator
<kc::impl_abstract_phylum*>,bool>) and once in 176.gcc (with %struct..0anon).




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61915 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-08 05:42:05 +00:00
Chris Lattner
d2fa781169 Implement the first half of PR3290: if there is a store of an
integer to a (transitive) bitcast the alloca and if that integer
has the full size of the alloca, then it clobbers the whole thing.
Handle this by extracting pieces out of the stored integer and 
filing them away in the SROA'd elements.

This triggers fairly frequently because the CFE uses integers to
pass small structs by value and the inliner exposes these.  For 
example, in kimwitu++, I see a bunch of these with i64 stores to
"%struct.std::pair<std::_Rb_tree_const_iterator<kc::impl_abstract_phylum*>,bool>"

In 176.gcc I see a few i32 stores to "%struct..0anon".

In the testcase, this is a difference between compiling test1 to:

_test1:
	subl	$12, %esp
	movl	20(%esp), %eax
	movl	%eax, 4(%esp)
	movl	16(%esp), %eax
	movl	%eax, (%esp)
	movl	(%esp), %eax
	addl	4(%esp), %eax
	addl	$12, %esp
	ret

vs:

_test1:
	movl	8(%esp), %eax
	addl	4(%esp), %eax
	ret

The second half of this will be to handle loads of the same form.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61853 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-07 08:11:13 +00:00
Chris Lattner
d93afec1db Factor a bunch of code out into a helper method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61852 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-07 07:18:45 +00:00
Chris Lattner
cf32186409 use continue to simplify code and reduce nesting, no functionality
change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61851 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-07 06:39:58 +00:00
Chris Lattner
56c3852fb4 Get TargetData once up front and cache as an ivar instead of
requerying it all over the place.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61850 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-07 06:34:28 +00:00
Chris Lattner
d356a7ee0e Use the hasAllZeroIndices predicate to simplify some
code, no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61849 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-07 06:25:07 +00:00
Chris Lattner
159c35b3ee Change m_ConstantInt and m_SelectCst to take their constant integers
as template arguments instead of as instance variables, exposing more
optimization opportunities to the compiler earlier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61776 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-05 23:53:12 +00:00
Evan Cheng
7e66c0d43a Find loop back edges only after empty blocks are eliminated.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61752 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-05 21:17:27 +00:00
Nick Lewycky
6cd0c048b8 Move the libcall annotating part from doFinalization to doInitialization.
Finalization occurs after all the FunctionPasses in the group have run, which
is clearly not what we want.

This also means that we have to make sure that we apply the right param 
attributes when creating a new function.

Also, add a missed optimization: strdup and strndup. NoCapture and 
NoAlias return!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61658 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-05 00:07:50 +00:00
Nick Lewycky
0f8df9a9ce Run a post-pass that marks known function declarations by name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61632 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-04 20:27:34 +00:00
Bill Wendling
d3d69781d3 Revert this transform. It was causing some dramatic slowdowns in a few tests. See PR3266.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61623 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-04 06:19:11 +00:00
Bill Wendling
94f0a38a00 Fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61538 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-01 01:19:59 +00:00
Bill Wendling
3479be91c4 Add transformation:
xor (or (icmp, icmp), true) -> and(icmp, icmp)

This is possible because of De Morgan's law.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61537 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-01 01:18:23 +00:00
Dale Johannesen
f6727b01a5 Revert 61362 and 61402 until SPEC breakage is fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61403 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 23:21:35 +00:00
Dale Johannesen
2fa2517324 This fixes the bug in 175.vpr. It doesn't fix the
other SPEC breakage.  I'll be reverting all recent
changes shortly, this checking is mostly so this
change doesn't get lost.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61402 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 23:05:26 +00:00
Dale Johannesen
e6ec25543f Fix the time regression I introduced in 464.h264ref with
my last patch to this file.

The issue there was that all uses of an IV inside a loop
are actually references to Base[IV*2], and there was one
use outside that was the same but LSR didn't see the base
or the scaling because it didn't recurse into uses outside
the loop; thus, it used base+IV*scale mode inside the loop
instead of pulling base out of the loop.  This was extra bad
because register pressure later forced both base and IV into
memory.  Doing that recursion, at least enough
to figure out addressing modes, is a good idea in general;
the change in AddUsersIfInteresting does this.  However,
there were side effects....

It is also possible for recursing outside the loop to
introduce another IV where there was only 1 before (if
the refs inside are not scaled and the ref outside is).
I don't think this is a common case, but it's in the testsuite.
It is right to be very aggressive about getting rid of
such introduced IVs (CheckForIVReuse and the handling of
nonzero RewriteFactor in StrengthReduceStridedIVUsers).
In the testcase in question the new IV produced this way
has both a nonconstant stride and a nonzero base, neither
of which was handled before.  And when inserting 
new code that feeds into a PHI, it's right to put such 
code at the original location rather than in the PHI's 
immediate predecessor(s) when the original location is outside 
the loop (a case that couldn't happen before)
(RewriteInstructionToUseNewBase); better to avoid making
multiple copies of it in this case.

Also, the mechanism for keeping SCEV's corresponding to GEP's
no longer works, as the GEP might change after its SCEV
is remembered, invalidating the SCEV, and we might get a bad
SCEV value when looking up the GEP again for a later loop.  
This also couldn't happen before, as we weren't recursing
into GEP's outside the loop.

I owe some testcases for this, want to get it in for nightly runs.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61362 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 02:12:52 +00:00
Owen Anderson
ae53c932b9 Don't forget to remove phi nodes from the value numbering table after we collapse them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61358 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 00:49:51 +00:00
Bill Wendling
30788b828a Comment clean-ups. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61354 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-22 22:32:22 +00:00
Bill Wendling
6d463f2efc Check that the instruction isn't in the value numbering scope.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61353 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-22 22:28:56 +00:00
Bill Wendling
75f02ee771 Simplification: Negate the operator== method instead of implementing a full operator!= method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61352 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-22 22:16:31 +00:00
Bill Wendling
70ded19b3f Add verification that deleted instruction isn't hiding in the PHI map.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61350 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-22 22:14:07 +00:00
Bill Wendling
ec40d50aa4 Verify removed in a few more places.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61349 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-22 21:57:30 +00:00
Bill Wendling
246dbbb8be Add verification functions to GVN which check to see that an instruction was
truely deleted. These will be expanded with further checks of all of the data
structures.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61347 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-22 21:36:08 +00:00
Nick Lewycky
13a09e298c Turn strcmp into memcmp, such as strcmp(P, "x") --> memcmp(P, "x", 2).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61297 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-21 00:19:21 +00:00
Nick Lewycky
9dce873c1a Remove redundant test for vector-nature. Scan the vector first to see whether
our optz'n will apply to it, then build the replacement vector only if needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61279 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-20 16:48:00 +00:00
Evan Cheng
ab63152871 - CodeGenPrepare does not split loop back edges but it only knows about back edges of single block loops. It now does a DFS walk to find loop back edges.
- Use SplitBlockPredecessors to factor out common predecessors of the critical edge destination. This is disabled for now due to some regressions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61248 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-19 18:03:11 +00:00
Bill Wendling
e533f4e343 Didn't mean to commit this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61222 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 22:19:50 +00:00
Bill Wendling
82c19ae10a Re-XFAIL this test until debug stuff settles down.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61219 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 22:13:31 +00:00
Nick Lewycky
19c2892677 Oops! Left out a line.
Simplifying the sdiv might allow further simplifications for our users.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61196 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 06:42:28 +00:00
Nick Lewycky
2a8f6597a3 Make all the vector elements positive in an srem of constant vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61195 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 06:31:11 +00:00
Dale Johannesen
a1d9cb1d46 Revert previous patch, appears to break bootstrap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61181 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 01:23:41 +00:00
Dale Johannesen
12b882cf53 Fix the time regression I introduced in 464.h264ref with
my last patch to this file.

The issue there was that all uses of an IV inside a loop
are actually references to Base[IV*2], and there was one
use outside that was the same but LSR didn't see the base
or the scaling because it didn't recurse into uses outside
the loop; thus, it used base+IV*scale mode inside the loop
instead of pulling base out of the loop.  This was extra bad
because register pressure later forced both base and IV into
memory.  Doing that recursion, at least enough
to figure out addressing modes, is a good idea in general;
the change in AddUsersIfInteresting does this.  However,
there were side effects....

It is also possible for recursing outside the loop to
introduce another IV where there was only 1 before (if
the refs inside are not scaled and the ref outside is).
I don't think this is a common case, but it's in the testsuite.
It is right to be very aggressive about getting rid of
such introduced IVs (CheckForIVReuse and the handling of
nonzero RewriteFactor in StrengthReduceStridedIVUsers).
In the testcase in question the new IV produced this way
has both a nonconstant stride and a nonzero base, neither
of which was handled before.  (This patch does not handle 
all the cases where this can happen.)  And when inserting 
new code that feeds into a PHI, it's right to put such 
code at the original location rather than in the PHI's 
immediate predecessor(s) when the original location is outside 
the loop (a case that couldn't happen before)
(RewriteInstructionToUseNewBase); better to avoid making
multiple copies of it in this case.

Everything above is exercised in
CodeGen/X86/lsr-negative-stride.ll (and ifcvt4 in ARM which is
the same IR).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61178 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 00:57:22 +00:00
Chris Lattner
5f4f84ba3e reapply this hunk from Bill's reversion in r61169, it is conservative
and safe and orthogonal from turning off load pre.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61177 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 00:51:32 +00:00
Bill Wendling
13d10096e1 Temporarily revert r61027. It was causing a bootstrap failure in "release" mode
with everyone's favorite error messages:

Comparing stages 2 and 3
warning: ./cc1-checksum.o differs
warning: ./cc1plus-checksum.o differs
Bootstrap comparison failure!
./c-decl.o differs
./cp/decl.o differs
./df-core.o differs
./gcc.o differs
./i386.o differs
./stor-layout.o differs
./tree-pretty-print.o differs
./tree.o differs
make[2]: *** [compare] Error 1
make[1]: *** [stage3-bubble] Error 2

See PR3227.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61169 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-17 23:31:20 +00:00
Dale Johannesen
b0390620d4 Clarify that the scale factor from CheckForIVReuse
can be negative.  Keep track of whether all uses of
an IV are outside the loop.  Some cosmetics; no
functional change.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61109 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-16 22:16:28 +00:00
Chris Lattner
2ba3b62149 Enable Load PRE. This teaches GVN to push partially redundant loads up the
CFG when there is exactly one predecessor where the load is not available.
This is designed to not increase code size but still eliminate partially
redundant loads.  This fires 1765 times on 403.gcc even though it doesn't
do critical edge splitting yet (the most common reason for it to fail).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61027 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 05:28:29 +00:00
Owen Anderson
c34d112362 Ifdef out some code that I didn't mean to enable by default yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61024 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 03:52:17 +00:00
Chris Lattner
f33131685b make GVN try to rename inputs to the resultant replaced values, which
cleans up the generated code a bit.  This should have the added benefit of
not randomly renaming functions/globals like my previous patch did. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61023 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 03:46:38 +00:00