Commit Graph

4253 Commits

Author SHA1 Message Date
Owen Anderson
83430bce1d Another step of stronger PHI elimination down.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43684 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-04 22:33:26 +00:00
Evan Cheng
9aeaf7593b If an interval is being undone clear its preference as well since the source interval may have been undone as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43670 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-04 08:32:21 +00:00
Evan Cheng
c92da3882e There are times when the coalescer would not coalesce away a copy but the copy
can be eliminated by the allocator is the destination and source targets the
same register. The most common case is when the source and destination registers
are in different class. For example, on x86 mov32to32_ targets GR32_ which
contains a subset of the registers in GR32.

The allocator can do 2 things:
1. Set the preferred allocation for the destination of a copy to that of its source.
2. After allocation is done, change the allocation of a copy destination (if
   legal) so the copy can be eliminated.

This eliminates 443 extra moves from 403.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43662 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-03 07:20:12 +00:00
Dan Gohman
111c4f897e Add std:: to sort calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43652 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-02 22:24:01 +00:00
Dan Gohman
b61f2f061f Change illegal uses of ++ to uses of STLExtra.h's next function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43651 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-02 22:22:02 +00:00
Evan Cheng
7277a7d031 One more extract_subreg coalescing bug.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43644 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-02 17:35:08 +00:00
Duncan Sands
e414cdacb4 Fix a thinko.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43639 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-02 15:18:06 +00:00
Duncan Sands
514ab348fd Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize.
The meaning of getTypeSize was not clear - clarifying it is important
now that we have x86 long double and arbitrary precision integers.
The issue with long double is that it requires 80 bits, and this is
not a multiple of its alignment.  This gives a primitive type for
which getTypeSize differed from getABITypeSize.  For arbitrary precision
integers it is even worse: there is the minimum number of bits needed to
hold the type (eg: 36 for an i36), the maximum number of bits that will
be overwriten when storing the type (40 bits for i36) and the ABI size
(i.e. the storage size rounded up to a multiple of the alignment; 64 bits
for i36).

This patch removes getTypeSize (not really - it is still there but
deprecated to allow for a gradual transition).  Instead there is:

(1) getTypeSizeInBits - a number of bits that suffices to hold all
values of the type.  For a primitive type, this is the minimum number
of bits.  For an i36 this is 36 bits.  For x86 long double it is 80.
This corresponds to gcc's TYPE_PRECISION.

(2) getTypeStoreSizeInBits - the maximum number of bits that is
written when storing the type (or read when reading it).  For an
i36 this is 40 bits, for an x86 long double it is 80 bits.  This
is the size alias analysis is interested in (getTypeStoreSize
returns the number of bytes).  There doesn't seem to be anything
corresponding to this in gcc.

(3) getABITypeSizeInBits - this is getTypeStoreSizeInBits rounded
up to a multiple of the alignment.  For an i36 this is 64, for an
x86 long double this is 96 or 128 depending on the OS.  This is the
spacing between consecutive elements when you form an array out of
this type (getABITypeSize returns the number of bytes).  This is
TYPE_SIZE in gcc.

Since successive elements in a SequentialType (arrays, pointers
and vectors) need to be aligned, the spacing between them will be
given by getABITypeSize.  This means that the size of an array
is the length times the getABITypeSize.  It also means that GEP
computations need to use getABITypeSize when computing offsets.
Furthermore, if an alloca allocates several elements at once then
these too need to be aligned, so the size of the alloca has to be
the number of elements multiplied by getABITypeSize.  Logically
speaking this doesn't have to be the case when allocating just
one element, but it is simpler to also use getABITypeSize in this
case.  So alloca's and mallocs should use getABITypeSize.  Finally,
since gcc's only notion of size is that given by getABITypeSize, if
you want to output assembler etc the same as gcc then getABITypeSize
is the size you want.

Since a store will overwrite no more than getTypeStoreSize bytes,
and a read will read no more than that many bytes, this is the
notion of size appropriate for alias analysis calculations.

In this patch I have corrected all type size uses except some of
those in ScalarReplAggregates, lib/Codegen, lib/Target (the hard
cases).  I will get around to auditing these too at some point,
but I could do with some help.

Finally, I made one change which I think wise but others might
consider pointless and suboptimal: in an unpacked struct the
amount of space allocated for a field is now given by the ABI
size rather than getTypeStoreSize.  I did this because every
other place that reserves memory for a type (eg: alloca) now
uses getABITypeSize, and I didn't want to make an exception
for unpacked structs, i.e. I did it to make things more uniform.
This only effects structs containing long doubles and arbitrary
precision integers.  If someone wants to pack these types more
tightly they can always use a packed struct.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43620 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 20:53:16 +00:00
Evan Cheng
0547bab214 - Coalesce extract_subreg when both intervals are relatively small.
- Some code clean up.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43606 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 06:22:48 +00:00
Duncan Sands
7169a2f9e8 Promotion of sdiv/srem/udiv/urem.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43551 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-31 08:57:43 +00:00
Duncan Sands
1bd3271b16 Add a newline at the end of the file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43550 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-31 08:49:24 +00:00
Owen Anderson
0bda0e8895 Add the skeleton of a better PHI elimination pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43542 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-31 03:37:57 +00:00
Owen Anderson
5d32ec4cb0 Some fixes to get MachineDomTree working better.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43541 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-31 03:30:14 +00:00
Dale Johannesen
25f1d08619 Make i64=expand_vector_elt(v2i64) work in 32-bit mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43535 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-31 00:32:36 +00:00
Evan Cheng
de1631bc85 Typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43511 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-30 20:11:21 +00:00
Duncan Sands
01405f9284 Add support for expanding trunc stores. Consider
storing an i170 on a 32 bit machine.  This is first
promoted to a trunc-i170 store of an i256.  On a
little-endian machine this expands to a store of
an i128 and a trunc-i42 store of an i128.  The
trunc-i42 store is further expanded to a trunc-i42
store of an i64, then to a store of an i32 and a
trunc-i10 store of an i32.  At this point the operand
type is legal (i32) and expansion stops (legalization
of the trunc-i10 needs to be handled in LegalizeDAG.cpp).
On big-endian machines the high bits are stored first,
and some bit-fiddling is needed in order to generate
aligned stores.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43499 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-30 12:50:39 +00:00
Duncan Sands
ba3b1d10fd If a call to getTruncStore is for a normal store,
offload to getStore rather than trying to handle
both cases at once (the assertions for example
assume the store really is truncating).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43498 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-30 12:40:58 +00:00
Dan Gohman
090b38a0da Fix a DAGCombiner abort on a bitcast from a scalar to a vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43470 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 20:44:42 +00:00
Evan Cheng
3c3ddb3a85 Enable more fold (sext (load x)) -> (sext (truncate (sextload x)))
transformation. Previously, it's restricted by ensuring the number of load uses
is one. Now the restriction is loosened up by allowing setcc uses to be
"extended" (e.g. setcc x, c, eq -> setcc sext(x), sext(c), eq).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43465 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 19:58:20 +00:00
Dan Gohman
9962054775 Add explicit keywords.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43464 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 19:52:04 +00:00
Duncan Sands
dc84650679 The guaranteed alignment of ptr+offset is only the minimum of
of offset and the alignment of ptr if these are both powers of
2.  While the ptr alignment is guaranteed to be a power of 2,
there is no reason to think that offset is.  For example, if
offset is 12 (the size of a long double on x86-32 linux) and
the alignment of ptr is 8, then the alignment of ptr+offset
will in general be 4, not 8.  Introduce a function MinAlign,
lifted from gcc, for computing the minimum guaranteed alignment.
I've tried to fix up everywhere under lib/CodeGen/SelectionDAG/.
I also changed some places that weren't wrong (because both values
were a power of 2), as a defensive change against people copying
and pasting the code.
Hopefully someone who cares about alignment will review the rest
of LLVM and fix up the remaining places.  Since I'm on x86 I'm
not very motivated to do this myself...


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43421 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-28 12:59:45 +00:00
Bill Wendling
984e986929 - Remove the hacky code that forces a memcpy. Alignment is taken care of in the
FE.
- Explicitly pass in the alignment of the load & store.
- XFAIL 2007-10-23-UnalignedMemcpy.ll because llc has a bug that crashes on
  unaligned pointers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43398 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-26 20:24:42 +00:00
Bill Wendling
da6efc5268 Changed XXX to FIXME, and added comment to the README file
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43359 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-25 19:49:32 +00:00
Bill Wendling
0713a22423 Added comment explaining why we are doing this check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43353 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-25 18:23:45 +00:00
Duncan Sands
2e606cfc7a Small formatting changes. Add a sanity check.
Use NVT rather than looking it up, since we have
it to hand.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43341 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-25 12:35:51 +00:00
Duncan Sands
cac99db7da Promote SETCC operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43340 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-25 12:32:31 +00:00
Duncan Sands
a3d10d808e Correctly extract the ValueType from a VTSDNode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43339 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-25 12:30:51 +00:00
Dale Johannesen
8eadd5a6db Another expansion for i64 multiply, suitable for PPC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43314 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-24 22:26:08 +00:00
Bill Wendling
30eeb3c6c0 Fix comment and use the "Size" variable that's already provided.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43271 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-23 23:36:57 +00:00
Bill Wendling
8b1c68cee4 If there's an unaligned memcpy to/from the stack, don't lower it. Just call the
memcpy library function instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43270 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-23 23:32:40 +00:00
Bill Wendling
803396fce2 This broke lots. Reverting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43264 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-23 22:04:26 +00:00
Bill Wendling
de09040946 Lowering a memcpy to the stack is killing PPC. The ARM and X86 backends already
have their own custom memcpy lowering code. This code needs to be factored out
into a target-independent lowering method with hooks to the backend. In the
meantime, just call memcpy if we're trying to copy onto a stack.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43262 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-23 21:30:25 +00:00
Evan Cheng
7bb175b4d1 It's possible to commute instrctions with more than 3 operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43256 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-23 20:14:40 +00:00
Evan Cheng
e11fb34381 isSubRegOf() is a dup of isSubRegister.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43249 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-23 06:51:50 +00:00
Evan Cheng
76500d52be Add missing paratheses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43227 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-22 19:42:28 +00:00
Duncan Sands
fec3ad3e5f Support for expanding extending loads of integers with
funky bit-widths.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43225 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-22 19:00:05 +00:00
Duncan Sands
245741d2a1 Fix up the logic for result expanding the various extension
operations so they work right for integers with funky
bit-widths.  For example, consider extending i48 to i64
on a 32 bit machine.  The i64 result is expanded to 2 x i32.
We know that the i48 operand will be promoted to i64, then
also expanded to 2 x i32.  If we had the expanded promoted
operand to hand, then expanding the result would be trivial.
Unfortunately at this stage we can only get hold of the
promoted operand.  So instead we kind of hand-expand, doing
explicit shifting and truncating to get the top and bottom
halves of the i64 operand into 2 x i32, which are then used
to expand the result.  This is harmless, because when the
promoted operand is finally expanded all this bit fiddling
turns into trivial operations which are eliminated either
by the expansion code itself or the DAG combiner.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43223 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-22 18:26:21 +00:00
Evan Cheng
cbfb9b27ef - Only perform the unfolding optimization when the folding in question is modref.
- Remove a bogus assertion.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43211 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-22 03:01:44 +00:00
Chris Lattner
d0e908e830 Add promote operand support for [su]int_to_fp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43204 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-20 22:57:56 +00:00
Chris Lattner
be5a0a4668 Add result promotion of FP_TO_*INT, fixing CodeGen/X86/trunc-to-bool.ll
with the new legalizer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43199 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-20 04:32:38 +00:00
Chris Lattner
aaeb0c8666 simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43198 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-20 04:09:48 +00:00
Chris Lattner
d20154c762 Implement promote and expand for operands of memcpy and friends.
This fixes CodeGen/X86/mem*.ll.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43197 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-20 04:07:07 +00:00
Evan Cheng
b9d5e7cdc9 Added missing curly braces which renders the if clause useless in debug build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43196 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-20 04:01:47 +00:00
Dale Johannesen
e526962fc5 Fix a few places vector operations were not getting
the operand's type from the right place.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43195 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-20 00:07:52 +00:00
Evan Cheng
66f7163545 Local spiller optimization:
Turn a store folding instruction into a load folding instruction. e.g.
     xorl  %edi, %eax
     movl  %eax, -32(%ebp)
     movl  -36(%ebp), %eax
     orl   %eax, -32(%ebp)
=>
     xorl  %edi, %eax
     orl   -36(%ebp), %eax
     mov   %eax, -32(%ebp)
This enables the unfolding optimization for a subsequent instruction which will
also eliminate the newly introduced store instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43192 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-19 21:23:22 +00:00
Bill Wendling
80629c85f1 Don't branch fold inline asm statements.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43191 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-19 21:09:55 +00:00
Duncan Sands
7f5f6851c3 Add support for a few more nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43190 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-19 20:29:48 +00:00
Dale Johannesen
b6210fc92b Redo "last ppc long double fix" as Chris wants.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43189 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-19 20:29:00 +00:00
Chris Lattner
f185e67844 Fix a really nasty vector miscompilation bill recently introduced.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43181 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-19 16:47:35 +00:00
Chris Lattner
1c4d492b94 rename ExpandOperation to ExpandOperationResult, as suggested
by Duncan


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43177 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-19 15:28:47 +00:00