Commit Graph

4725 Commits

Author SHA1 Message Date
Lauro Ramos Venancio 192c07b727 CBackend: Implement unaligned load/store.
llvm-svn: 46646
2008-02-01 21:25:59 +00:00
Duncan Sands 9aa789fda3 Don't drop function/call return attributes like 'nounwind'.
llvm-svn: 46645
2008-02-01 20:37:16 +00:00
Dale Johannesen 56d4903db5 Accept getelementptr starting at GV with all 0 indices as a
legitimate way of representing global variable GV in debug info.

llvm-svn: 46565
2008-01-30 19:00:21 +00:00
Tanya Lattner cee9d51be9 Pointers change size depending upon the target. Remove them to make the test more stable.
llvm-svn: 46548
2008-01-30 05:15:15 +00:00
Owen Anderson 4e4b116750 Make DSE much more aggressive by performing DCE earlier. Update a testcase to reflect this increased aggressiveness.
llvm-svn: 46542
2008-01-30 01:24:47 +00:00
Chris Lattner b9e5b8fb9e Fix a bug where scalarrepl would discard offset if type would match.
In practice this can only happen on code with already undefined behavior, 
but this is still a good thing to handle correctly.

llvm-svn: 46539
2008-01-30 00:39:15 +00:00
Evan Cheng a13e5146d4 Update this test case.
llvm-svn: 46526
2008-01-29 19:30:05 +00:00
Chris Lattner ade0abb498 Don't let globalopt hack on volatile loads or stores.
llvm-svn: 46523
2008-01-29 19:01:37 +00:00
Chris Lattner 17819d971e eliminate additions of 0.0 when they are obviously dead. This has to be careful to
avoid turning -0.0 + 0.0 -> -0.0 which is incorrect.

llvm-svn: 46499
2008-01-29 06:52:45 +00:00
Owen Anderson 95bf1d4d7b Add a testcase for eliminating memcpy's at the end of functions. Forgot to commit this with my last commit.
llvm-svn: 46497
2008-01-29 06:40:32 +00:00
Chris Lattner f4e5e556fd Add target triples to these so they don't fail on linux.
llvm-svn: 46496
2008-01-29 06:26:07 +00:00
Duncan Sands 1e7ec74ad3 This would be better done as an executable test.
llvm-svn: 46493
2008-01-29 06:04:54 +00:00
Duncan Sands aaaeee2ac0 After recent changes we fail to optimize this test
sufficiently to have it pass.  I'm removing it from
the testsuite and adding it to PR452 instead.

llvm-svn: 46492
2008-01-29 05:57:23 +00:00
Devang Patel 67fa0521b6 Filter loops that subtract induction variables.
These loops are not yet handled.

Fix PR 1912.

llvm-svn: 46484
2008-01-29 02:20:41 +00:00
Scott Michel ceae3bbf4d Overhaul Cell SPU's addressing mode internals so that there are now
only two addressing mode nodes, SPUaform and SPUindirect (vice the
three previous ones, SPUaform, SPUdform and SPUxform). This improves
code somewhat because we now avoid using reg+reg addressing when
it can be avoided. It also simplifies the address selection logic,
which was the main point for doing this.

Also, for various global variables that would be loaded using SPU's
A-form addressing, prefer D-form offs[reg] addressing, keeping the
base in a register if the variable is used more than once.

llvm-svn: 46483
2008-01-29 02:16:57 +00:00
Devang Patel 7bcf58f8a4 New test.
llvm-svn: 46479
2008-01-29 01:10:04 +00:00
Bill Wendling f0b7d4993f Add test to make sure that #pragma mark/error doesn't error if there are
unbalanced quotes.

llvm-svn: 46476
2008-01-29 00:41:29 +00:00
Duncan Sands 2a80ba8c7c Pure/const functions with ByVal parameters cannot
be marked readonly either.

llvm-svn: 46456
2008-01-28 19:25:47 +00:00
Chris Lattner a116071547 this test is now compiled into the right thing.
llvm-svn: 46454
2008-01-28 17:38:46 +00:00
Duncan Sands 54af54fe08 Make this more likely to be passed byval.
llvm-svn: 46451
2008-01-28 10:35:11 +00:00
Nick Lewycky 8ea81e8ba4 Handle some more combinations of extend and icmp. Fixes PR1940.
llvm-svn: 46431
2008-01-28 03:48:02 +00:00
Chris Lattner 710b441174 Fix PR1932 by disabling an xform invalid for fdiv.
llvm-svn: 46429
2008-01-28 00:58:18 +00:00
Chris Lattner 1b706dd680 Fix PR1938 by forcing the code that uses an undefined value to branch one
way or the other.  Rewriting the code itself prevents subsequent analysis
passes from making contradictory conclusions about the code that could 
cause an infeasible path to be made feasible.

llvm-svn: 46427
2008-01-28 00:32:30 +00:00
Chris Lattner 34d6b6a319 Update this test. Due to dag combiner improvements, we now compile
f7/f11 to:

_f7:
	eor r0, r0, #2, 2 @ -2147483648
	bx lr
_f11:
	bic r0, r0, #2, 2 @ -2147483648
	bx lr

instead of:

_f7:
	fmsr s0, r0
	fnegs s0, s0
	fmrs r0, s0
	bx lr

_f11:
	fmsr s0, r0
	fabss s0, s0
	fmrs r0, s0
	bx lr

llvm-svn: 46423
2008-01-27 23:26:37 +00:00
Nick Lewycky efb16f7057 Be more careful modifying the use_list while also iterating through it.
llvm-svn: 46417
2008-01-27 18:35:00 +00:00
Duncan Sands 053c9871cd Revert r46393: readonly/readnone functions are no
longer allowed to write through byval arguments.

llvm-svn: 46416
2008-01-27 18:12:58 +00:00
Chris Lattner 888560d62c Implement some dag combines that allow doing fneg/fabs/fcopysign in integer
registers if used by a bitconvert or using a bitconvert.  This allows us to
avoid constant pool loads and use cheaper integer instructions when the
values come from or end up in integer regs anyway.  For example, we now 
compile CodeGen/X86/fp-in-intregs.ll to:

_test1:
	movl	$2147483648, %eax
	xorl	4(%esp), %eax
	ret
_test2:
	movl	$1065353216, %eax
	orl	4(%esp), %eax
	andl	$3212836864, %eax
	ret

Instead of:
_test1:
	movss	4(%esp), %xmm0
	xorps	LCPI2_0, %xmm0
	movd	%xmm0, %eax
	ret
_test2:
	movss	4(%esp), %xmm0
	andps	LCPI3_0, %xmm0
	movss	LCPI3_1, %xmm1
	andps	LCPI3_2, %xmm1
	orps	%xmm0, %xmm1
	movd	%xmm1, %eax
	ret

bitconverts can happen due to various calling conventions that require
fp values to passed in integer regs in some cases, e.g. when returning
a complex.

llvm-svn: 46414
2008-01-27 17:42:27 +00:00
Bill Wendling 8c491162d2 The CorrelatedExpressions pass is now no more.
llvm-svn: 46409
2008-01-27 06:13:32 +00:00
Chris Lattner fa1e7eef30 Fold fptrunc(add (fpextend x), (fpextend y)) -> add(x,y), as GCC does.
llvm-svn: 46406
2008-01-27 05:29:54 +00:00
Chris Lattner 596704405f New test to verify that "merging 4 loads into a vec load" continues to work and
continues to infer alignment info.

llvm-svn: 46403
2008-01-26 20:06:45 +00:00
Chris Lattner e30e33af4f Infer alignment of loads and increase their alignment when we can tell they are
from the stack.  This allows us to compile stack-align.ll to:

_test:
	movsd	LCPI1_0, %xmm0
	movapd	%xmm0, %xmm1
***	andpd	4(%esp), %xmm1
	andpd	_G, %xmm0
	addsd	%xmm1, %xmm0
	movl	20(%esp), %eax
	movsd	%xmm0, (%eax)
	ret

instead of:

_test:
	movsd	LCPI1_0, %xmm0
**	movsd	4(%esp), %xmm1
**	andpd	%xmm0, %xmm1
	andpd	_G, %xmm0
	addsd	%xmm1, %xmm0
	movl	20(%esp), %eax
	movsd	%xmm0, (%eax)
	ret

llvm-svn: 46401
2008-01-26 19:45:50 +00:00
Chris Lattner 364963d41c remove a useless xfailed test.
llvm-svn: 46400
2008-01-26 19:35:46 +00:00
Duncan Sands dc157a4f0a Invert this test, because it is wrong if we allow
readonly functions to use byval parameters as local
storage (how much do we want this?).

llvm-svn: 46399
2008-01-26 12:33:01 +00:00
Bill Wendling 1a17ef02c8 If there's no instructions being emitted on X86 for a function, emit a
nop. Emit the nop directly for PPC.

llvm-svn: 46398
2008-01-26 09:03:52 +00:00
Bill Wendling a60c61dc1a Need to convert to LLVM code and not C.
llvm-svn: 46397
2008-01-26 06:56:08 +00:00
Bill Wendling 0b973210f8 Rename the .c to .ll
llvm-svn: 46396
2008-01-26 06:53:40 +00:00
Bill Wendling 0f69974fdb Move testcase to the code gen directory.
llvm-svn: 46395
2008-01-26 06:53:06 +00:00
Duncan Sands c4dc3dc3a2 Create an explicit copy for byval parameters even
when inlining a readonly function.

llvm-svn: 46393
2008-01-26 06:41:49 +00:00
Bill Wendling 0862e3421d If we have a function like this:
void bork() {
  int *address = 0;
  *address = 0;
}

It's compiled into LLVM code that looks like this:

define void @bork() noreturn nounwind  {
entry:
        unreachable
}

This is bad on some platforms (like PPC) because it will generate the label for
the function but no body. The label could end up being associated with some
non-code related stuff, like a section. This places a "trap" instruction if the
SimplifyCFG pass removed all code from the function leaving only one
"unreachable" instruction.

llvm-svn: 46387
2008-01-26 01:43:44 +00:00
Devang Patel 8797851fbe Add another testcase.
llvm-svn: 46385
2008-01-26 01:21:48 +00:00
Chris Lattner 31e9edce1c Fix some bugs in SimplifyNodeWithTwoResults where it would call deletenode to
delete a node even if it was not dead in some cases.  Instead, just add it to
the worklist.  Also, make sure to use the CombineTo methods, as it was doing
things that were unsafe: the top level combine loop could touch dangling memory.

This fixes CodeGen/Generic/2008-01-25-dag-combine-mul.ll

llvm-svn: 46384
2008-01-26 01:09:19 +00:00
Evan Cheng 2df73ea849 New test case.
llvm-svn: 46382
2008-01-26 00:35:43 +00:00
Chris Lattner 0af861c43a add a testcase for a bug Duncan pointed out.
llvm-svn: 46372
2008-01-25 22:36:24 +00:00
Duncan Sands e5433a90ce Test for PR1942.
llvm-svn: 46357
2008-01-25 17:36:44 +00:00
Owen Anderson 6af19fd1e2 DeadStoreElimination can treat byval parameters as if there were alloca's for the purpose of removing end-of-function stores.
llvm-svn: 46351
2008-01-25 10:10:33 +00:00
Chris Lattner 84ab724e06 Add target-specific dag combines for FAND(x,0) and FOR(x,0). This allows
us to compile:

double test(double X) {
  return copysign(0.0, X);
}

into:

_test:
	andpd	LCPI1_0(%rip), %xmm0
	ret

instead of:
_test:
	pxor	%xmm1, %xmm1
	andpd	LCPI1_0(%rip), %xmm1
	movapd	%xmm0, %xmm2
	andpd	LCPI1_1(%rip), %xmm2
	movapd	%xmm1, %xmm0
	orpd	%xmm2, %xmm0
	ret

llvm-svn: 46344
2008-01-25 05:46:26 +00:00
Devang Patel 0c4e4da654 New test.
llvm-svn: 46333
2008-01-24 23:55:34 +00:00
Chris Lattner 9104d71269 Teach basicaa that 'byval' arguments define a new memory location that
can't be aliased to other known objects.  This allows us to know that byval 
pointer args don't alias globals, etc.

llvm-svn: 46315
2008-01-24 18:00:32 +00:00
Chris Lattner a91f77eaac Significantly simplify and improve handling of FP function results on x86-32.
This case returns the value in ST(0) and then has to convert it to an SSE
register.  This causes significant codegen ugliness in some cases.  For 
example in the trivial fp-stack-direct-ret.ll testcase we used to generate:

_bar:
	subl	$28, %esp
	call	L_foo$stub
	fstpl	16(%esp)
	movsd	16(%esp), %xmm0
	movsd	%xmm0, 8(%esp)
	fldl	8(%esp)
	addl	$28, %esp
	ret

because we move the result of foo() into an XMM register, then have to
move it back for the return of bar.

Instead of hacking ever-more special cases into the call result lowering code
we take a much simpler approach: on x86-32, fp return is modeled as always 
returning into an f80 register which is then truncated to f32 or f64 as needed.
Similarly for a result, we model it as an extension to f80 + return.

This exposes the truncate and extensions to the dag combiner, allowing target
independent code to hack on them, eliminating them in this case.  This gives 
us this code for the example above:

_bar:
	subl	$12, %esp
	call	L_foo$stub
	addl	$12, %esp
	ret

The nasty aspect of this is that these conversions are not legal, but we want
the second pass of dag combiner (post-legalize) to be able to hack on them.
To handle this, we lie to legalize and say they are legal, then custom expand
them on entry to the isel pass (PreprocessForFPConvert).  This is gross, but
less gross than the code it is replacing :)

This also allows us to generate better code in several other cases.  For 
example on fp-stack-ret-conv.ll, we now generate:

_test:
	subl	$12, %esp
	call	L_foo$stub
	fstps	8(%esp)
	movl	16(%esp), %eax
	cvtss2sd	8(%esp), %xmm0
	movsd	%xmm0, (%eax)
	addl	$12, %esp
	ret

where before we produced (incidentally, the old bad code is identical to what
gcc produces):

_test:
	subl	$12, %esp
	call	L_foo$stub
	fstpl	(%esp)
	cvtsd2ss	(%esp), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	16(%esp), %eax
	movsd	%xmm0, (%eax)
	addl	$12, %esp
	ret

Note that we generate slightly worse code on pr1505b.ll due to a scheduling 
deficiency that is unrelated to this patch.

llvm-svn: 46307
2008-01-24 08:07:48 +00:00
Chris Lattner 001d781c41 take these with a pr #
llvm-svn: 46303
2008-01-24 06:35:44 +00:00