Commit Graph

1609 Commits

Author SHA1 Message Date
Chris Lattner
dd12f96c5e Fold (-x + -y) -> -(x+y) which promotes better association, fixing
the second half of PR2047


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47244 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-17 21:03:36 +00:00
Chris Lattner
0b0803ae15 Split up subtracts into add+negate if they have a reassociable use or operand
that is also a subtract.  This implements PR2047 and Transforms/Reassociate/subtest2.ll 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47241 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-17 20:51:26 +00:00
Chris Lattner
f06c3c29ac upgrade and simplify this test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47240 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-17 20:48:43 +00:00
Duncan Sands
3d5378ff8e Remove any 'nest' parameter attributes if the function
is not passed as an argument to a trampoline intrinsic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47220 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-16 20:56:04 +00:00
Devang Patel
9b03daa2a3 If loop header is also loop exiting block then OrigPN is incoming value for B loop header.
Fixes PR 2030.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47141 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-14 23:18:47 +00:00
Chris Lattner
8c5c22f610 Fix PR2029
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47129 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-14 19:18:13 +00:00
Nick Lewycky
c91b49b890 Testcase for PR2032.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47113 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-14 07:15:11 +00:00
Devang Patel
ea06906559 A loop latch phi node may have uses inside loop, not just in loop header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47093 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 22:23:07 +00:00
Devang Patel
23067dfeac While moving exit condition, do not drop loop latch on the floor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47089 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 22:06:36 +00:00
Devang Patel
02c4836f3d Keep track of exit value operand number when operands are swapped.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47082 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 19:48:48 +00:00
Eli Friedman
35327b3e57 Add a note pointing to PR1996.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47055 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 07:56:04 +00:00
Eli Friedman
261c704da1 Add test for PR1996. (This is my first time adding a test for a
transform, so please review.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47050 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 06:55:57 +00:00
Owen Anderson
30b4bd4d10 Re-apply the patch to improve the optimizations of memcpy's, with several
bugs fixed.  This now passes PPC bootstrap.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47026 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-12 21:15:18 +00:00
Devang Patel
82ada54da0 Fix PR 1995.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46898 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-08 22:49:13 +00:00
Bill Wendling
e00fec554b Temporarily reverting:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080128/057882.html

This is causing a miscompilation on PPC G5 and just now seeing it on iMac x86-64.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46822 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-06 20:03:07 +00:00
Chris Lattner
7c95debb49 Fix a bug compiling PR1978 (perhaps not the only one though) which
was incorrectly simplifying "x == (gep x, 1, i)" into false, even 
though i could be negative.  As it turns out, all the code to 
handle this already existed, we just need to disable the incorrect
optimization case and let the general case handle it.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46739 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-05 04:45:32 +00:00
Owen Anderson
d02c0bc984 Make this test more aggressive, to cover recent improvements.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46695 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-04 04:55:24 +00:00
Owen Anderson
6f7a52d300 Allow GVN to hack on memcpy's, making them open to further optimization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46693 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-04 02:59:58 +00:00
Nick Lewycky
f2a5f012f3 Tag this test with the PR reference.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46688 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-03 16:35:19 +00:00
Nick Lewycky
5be2920149 There are some cases where icmp(add) can be folded into a new icmp. Handle them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46687 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-03 16:33:09 +00:00
Duncan Sands
532d022794 Don't drop function/call return attributes like 'nounwind'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46645 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-01 20:37:16 +00:00
Owen Anderson
772601a885 Make DSE much more aggressive by performing DCE earlier. Update a testcase to reflect this increased aggressiveness.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46542 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-30 01:24:47 +00:00
Chris Lattner
b10e0da065 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46539 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-30 00:39:15 +00:00
Chris Lattner
c69d3c9442 Don't let globalopt hack on volatile loads or stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46523 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 19:01:37 +00:00
Chris Lattner
2454a2e0c3 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46499 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 06:52:45 +00:00
Owen Anderson
cca1867ab7 Add a testcase for eliminating memcpy's at the end of functions. Forgot to commit this with my last commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46497 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 06:40:32 +00:00
Devang Patel
c840da14c6 Filter loops that subtract induction variables.
These loops are not yet handled.

Fix PR 1912.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46484 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 02:20:41 +00:00
Chris Lattner
349c72a35d this test is now compiled into the right thing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46454 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-28 17:38:46 +00:00
Nick Lewycky
4189a538e4 Handle some more combinations of extend and icmp. Fixes PR1940.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46431 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-28 03:48:02 +00:00
Chris Lattner
25feae555d Fix PR1932 by disabling an xform invalid for fdiv.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46429 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-28 00:58:18 +00:00
Chris Lattner
05bb789430 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46427 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-28 00:32:30 +00:00
Nick Lewycky
c837abee2f Be more careful modifying the use_list while also iterating through it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46417 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-27 18:35:00 +00:00
Duncan Sands
d82375c1c4 Revert r46393: readonly/readnone functions are no
longer allowed to write through byval arguments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46416 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-27 18:12:58 +00:00
Bill Wendling
67fed1c8f2 The CorrelatedExpressions pass is now no more.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46409 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-27 06:13:32 +00:00
Chris Lattner
b753065f6d Fold fptrunc(add (fpextend x), (fpextend y)) -> add(x,y), as GCC does.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46406 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-27 05:29:54 +00:00
Duncan Sands
63b2c2dde7 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?).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46399 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-26 12:33:01 +00:00
Owen Anderson
e3c36f6758 DeadStoreElimination can treat byval parameters as if there were alloca's for the purpose of removing end-of-function stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46351 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-25 10:10:33 +00:00
Nick Lewycky
e6b0c0036a Multiply can be evaluated in a different type, so long as the target type has
a smaller bitwidth.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46244 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-22 05:08:48 +00:00
Evan Cheng
e6d5c77d5d Test case for varargs parameter attribute issue I just fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46127 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-17 07:26:31 +00:00
Chris Lattner
ab04e13a1f Fix arg promotion to propagate the correct attrs on the calls to
promoted functions.  This is important for varargs calls in 
particular.  Thanks to duncan for providing a great testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46108 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-17 01:17:03 +00:00
Devang Patel
8c231e5dda Do not strip llvm.used values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46045 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-16 03:33:05 +00:00
Chris Lattner
beb168992f add a test to ensure that argpromote of one argument doesn't
break the byval attr on some other argument.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46025 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15 22:38:12 +00:00
Duncan Sands
b0c9b93bb4 I noticed that the trampoline straightening transformation could
drop attributes on varargs call arguments.  Also, it could generate
invalid IR if the transformed call already had the 'nest' attribute
somewhere (this can never happen for code coming from llvm-gcc,
but it's a theoretical possibility).  Fix both problems.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45973 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-14 19:52:09 +00:00
Chris Lattner
941db495b8 Fix the miscompilation of MiBench/consumer-lame that was exposed by Evan's
byval work.  This miscompilation is due to the program indexing an array out
of range and us doing a transformation that broke this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45949 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-14 02:09:12 +00:00
Chris Lattner
37ac608623 Turn a memcpy from a double* into a load/store of double instead of
a load/store of i64.  The later prevents promotion/scalarrepl of the
source and dest in many cases.

This fixes the 300% performance regression of the byval stuff on 
stepanov_v1p2.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45945 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-14 00:28:35 +00:00
Chris Lattner
ee2b7a4530 Fix PR1907, a nasty miscompilation because instcombine didn't
realize that ne & sgt  was a signed comparison (it was only 
looking at whether the left compare was signed).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45937 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-13 20:59:02 +00:00
Duncan Sands
e1e520f601 When turning a call to a bitcast function into a direct call,
if this becomes a varargs call then deal correctly with any
parameter attributes on the newly vararg call arguments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45931 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-13 08:02:44 +00:00
Chris Lattner
92938b7145 we don't have to make an explicit copy of a byval argument when
inlining a function if we know that the function does not write
to *any* memory.  This implements test/Transforms/Inline/byval2.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45912 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-12 18:54:29 +00:00
Duncan Sands
bfc5ae6df0 When DAE drops the varargs part of a function, ensure any
attributes on the vararg call arguments are also dropped.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45892 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-11 23:13:45 +00:00
Chris Lattner
10603e0c84 Teach argpromote to ruthlessly hack small byval structs when it can
get away with it, which exposes opportunities to eliminate the memory
objects entirely.  For example, we now compile byval.ll to:

define internal void @f1(i32 %b.0, i64 %b.1) {
entry:
	%tmp2 = add i32 %b.0, 1		; <i32> [#uses=0]
	ret void
}

define i32 @main() nounwind  {
entry:
	call void @f1( i32 1, i64 2 )
	ret i32 0
}

This seems like it would trigger a lot for code that passes around small
structs (e.g. SDOperand's or _Complex)...



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45886 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-11 22:31:41 +00:00
Chris Lattner
c93adca358 When inlining a functino with a byval argument, make an explicit
copy of it in case the callee modifies the struct.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45853 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-11 06:09:30 +00:00
Chris Lattner
f9d9e45225 Implement PR1795, an instcombine hack for forming GEPs with integer pointer arithmetic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45745 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-08 07:23:51 +00:00
Duncan Sands
ad9a9e1559 The transform that tries to turn calls to bitcast functions into
direct calls bails out unless caller and callee have essentially
equivalent parameter attributes.  This is illogical - the callee's
attributes should be of no relevance here.  Rework the logic, which
incidentally fixes a crash when removed arguments have attributes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45658 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-06 18:27:01 +00:00
Duncan Sands
a9d0c9dc58 When transforming a call to a bitcast function into
a direct call with cast parameters and cast return
value (if any), instcombine was prepared to cast any
non-void return value into any other, whether castable
or not.  Add a new predicate for testing whether casting
is valid, and check it both for the return value and
(as a cleanup) for the parameters.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45657 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-06 10:12:28 +00:00
Chris Lattner
5a62d0a038 remove a couple more unsafe xforms in the face of overflow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45613 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-05 01:22:42 +00:00
Chris Lattner
9027b3cc7f Fix PR1896
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45568 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-04 05:04:53 +00:00
Chris Lattner
3d73bce2d0 don't hoist FP additions into unconditional adds + selects. This
could theoretically introduce a trap, but is also a performance issue.
This speeds up ptrdist/ks by 8%.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45533 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-03 07:25:26 +00:00
Bill Wendling
4c07450305 Update this testcase. The output needs to be disabled to pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45478 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-01 01:34:36 +00:00
Chris Lattner
741c0aea08 dead calls to llvm.stacksave can be deleted, even though they
have potential side-effects.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45392 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 00:59:12 +00:00
Chris Lattner
26d5f661d6 upgrade this test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45391 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 00:57:06 +00:00
Devang Patel
c49c08f747 Test -simplifycfg only.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45389 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-28 22:59:48 +00:00
Owen Anderson
2910f68a52 Add a testcase for my recent InstCombine fix, written by Nicholas.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45386 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-28 21:08:43 +00:00
Chris Lattner
8999dd3c68 implement InstCombine/shift-trunc-shift.ll. This allows
us to compile:
#include <math.h>
int t1(double d) { return signbit(d); }

into:

_t1:
	movd	%xmm0, %rax
	shrq	$63, %rax
	ret

instead of:

_t1:
	movd	%xmm0, %rax
	shrq	$32, %rax
	shrl	$31, %eax
	ret

on x86-64.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45311 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-22 09:07:47 +00:00
Devang Patel
01666bf74b If succ has succ itself as one of the predecessors then do
not merge current bb and succ even if bb's terminator is
unconditional branch to succ.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45305 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-22 01:32:53 +00:00
Duncan Sands
110c835039 Make DAE not wipe out attributes on calls, and not drop
return attributes on the floor.  In the case of a call
to a varargs function where the varargs arguments are
being removed, any call attributes on those arguments
need to be dropped.  I didn't do this because I plan to
make it illegal to have such attributes (see next patch).
With this change, compiling the gcc filter2 eh test at -O0
and then running opt -std-compile-opts on it results in
a correctly working program (compiling at -O1 or higher
results in the test failing due to a problem with how we
output eh info into the IR).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45285 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-21 19:16:16 +00:00
Christopher Lamb
103e1a3118 Implement review feedback, including additional transforms
(icmp slt (sub A B) 1) -> (icmp sle A B)
icmp sgt (sub A B) -1) -> (icmp sge A B)

and add testcase.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45256 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-20 07:21:11 +00:00
Duncan Sands
f0c3354d99 When inlining through an 'nounwind' call, mark inlined
calls 'nounwind'.  It is important for correct C++
exception handling that nounwind markings do not get
lost, so this transformation is actually needed for
correctness.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45218 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-19 21:13:37 +00:00
Christopher Lamb
fd8b1fd7f6 Remove an orthogonal transformation of the selection condition from my most recent submission.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45169 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-18 20:30:28 +00:00
Christopher Lamb
f311f53a0f Fix typos.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45159 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-18 09:45:40 +00:00
Christopher Lamb
30f017ad89 Fold certain additions through selects (and their compares) so as to eliminate subtractions. This code is often produced by the SMAX expansion in SCEV.
This implements test/Transforms/InstCombine/2007-12-18-AddSelCmpSub.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45158 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-18 09:34:41 +00:00
Duncan Sands
fd7b326bea Make invokes of inline asm legal. Teach codegen
how to lower them (with no attempt made to be
efficient, since they should only occur for
unoptimized code).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45108 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-17 18:08:19 +00:00
Duncan Sands
ece2c04d53 Make instcombine promote inline asm calls to 'nounwind'
calls.  Remove special casing of inline asm from the
inliner.  There is a potential problem: the verifier
rejects invokes of inline asm (not sure why).  If an
asm call is not marked "nounwind" in some .ll, and
instcombine is not run, but the inliner is run, then
an illegal module will be created.  This is bad but
I'm not sure what the best approach is.  I'm tempted
to remove the check in the verifier...


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45073 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-16 15:51:49 +00:00
Wojciech Matyjewicz
ed2232502e 1. "Upgrage" comments.
2. Using zero-extended value of Scale and unsigned division is safe provided
   that Scale doesn't have the sign bit set.
   Previously these 2 instructions:
        %p = bitcast [100 x {i8,i8,i8}]* %x to i8*
        %q = getelementptr i8* %p, i32 -4
   were combined into:
        %q = getelementptr [100 x { i8, i8, i8 }]* %x, i32 0,
               i32 1431655764, i32 0
   what was incorrect.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44936 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-12 15:21:32 +00:00
Chris Lattner
1afab9c1e0 Implement constant folding if vector<->vector bitcasts where the number
of source/dest elements changes.  This implements
test/Transforms/InstCombine/bitcast-vector-fold.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44855 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-11 07:29:44 +00:00
Chris Lattner
f286f6fd93 Fix PR1850 by removing an unsafe transformation from VMCore/ConstantFold.cpp.
Reimplement the xform in Analysis/ConstantFolding.cpp where we can use
targetdata to validate that it is safe.  While I'm in there, fix some const
correctness issues and generalize the interface to the "operand folder".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44817 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-10 22:53:04 +00:00
Duncan Sands
cbb8badce8 Make PruneEH update the nounwind/noreturn attributes
on functions as it calculates them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44802 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-10 19:09:40 +00:00
Devang Patel
5ffdc56f53 If ExitValue operand is also defined in Loop header then
insert new ExitValue after this operand definition.

This fixes PR1828.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44539 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-03 19:17:21 +00:00
Duncan Sands
afa3b6da11 Add some convenience methods for querying attributes, and
use them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44403 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-28 17:07:01 +00:00
Duncan Sands
dc024674ff Fix PR1146: parameter attributes are longer part of
the function type, instead they belong to functions
and function calls.  This is an updated and slightly
corrected version of Reid Spencer's original patch.
The only known problem is that auto-upgrading of
bitcode files doesn't seem to work properly (see
test/Bitcode/AutoUpgradeIntrinsics.ll).  Hopefully
a bitcode guru (who might that be? :) ) will fix it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44359 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-27 13:23:08 +00:00
Nick Lewycky
c54c561c9f Add new SCEV, SCEVSMax. This allows LLVM to analyze do-while loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44319 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-25 22:41:31 +00:00
Chris Lattner
cfa597569d Implement PR1822
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44318 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-25 21:27:53 +00:00
Duncan Sands
827cde1c83 Fix PR1816. If a bitcast of a function only exists because of a
trivial difference in function attributes, allow calls to it to
be converted to direct calls.  Based on a patch by Török Edwin.
While there, move the various lists of mutually incompatible
parameters etc out of the verifier and into ParameterAttributes.h.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44315 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-25 14:10:56 +00:00
Chris Lattner
9e513acd31 Fix PR1816, by correcting the broken definition of APInt::countTrailingZeros.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44296 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-23 22:42:31 +00:00
Duncan Sands
e4dc717585 Ding dong, the DoesntAccessMemoryFns and
OnlyReadsMemoryFns tables are dead!  We
get more, and more accurate, information
from gcc via the readnone and readonly
function attributes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44288 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-23 19:30:27 +00:00
Chris Lattner
42b5e08e71 Fix a bug where we'd try to find a scev value for a bitcast operand,
even though the bitcast operand did not have integer type.  This fixes
PR1814.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44286 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-23 08:46:22 +00:00
Chris Lattner
eec8b9a7d6 Fix PR1817.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44284 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-22 23:47:13 +00:00
Duncan Sands
73d4bb6676 Turn invokes of nounwind functions into ordinary calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44280 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-22 22:24:59 +00:00
Duncan Sands
5ef7be79e0 Readonly/readnone functions are allowed to throw
exceptions, so don't turn invokes of them into
calls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44278 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-22 21:40:06 +00:00
Chris Lattner
a7d1ab0ab3 Fix PR1800 by correcting mistaken logic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44188 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-16 06:04:17 +00:00
Chris Lattner
1b12d8855d Implement PR1796 and Transforms/SimplifyCFG/noreturn-call.ll
by inserting unreachable after no-return calls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44099 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-14 06:19:25 +00:00
Chris Lattner
59ab338882 upgrade test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44067 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-13 21:42:48 +00:00
Chris Lattner
b42c8f7101 Implement PR1786 by iterating between dead cycle elimination
and simplifycfg in the rare cases when it is needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44044 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-13 07:32:38 +00:00
Chris Lattner
7b52fe7272 Tighten up a check for folding away loads from (newly constant) globals. This
fixes a crash on Transforms/GlobalOpt/2007-11-09-GEP-GEP-Crash.ll and 
rdar://5585488.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43949 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-09 17:33:02 +00:00
Andrew Lenharth
b410df995c Better check
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43897 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-08 18:45:15 +00:00
Andrew Lenharth
ab9338eb9f Fix PR1780
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43893 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-08 17:39:28 +00:00
Chris Lattner
cf5008a792 Implement PR1777 by detecting dependent phis that
all compute the same value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43777 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-06 21:52:06 +00:00
Dan Gohman
cff550995b Fix an abort in instcombine when folding creates a vector rem instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43743 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-05 23:16:33 +00:00
Devang Patel
5d01aa484f If a value is incoming from outside the loop then the value does not need remapping and the value is never tracked through LastValueMap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43728 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-05 19:32:30 +00:00
Duncan Sands
3cb3650a27 Change uses of getTypeSize to getABITypeSize, getTypeStoreSize
or getTypeSizeInBits as appropriate in ScalarReplAggregates.
The right change to make was not always obvious, so it would
be good to have an sroa guru review this.  While there I noticed
some bugs, and fixed them: (1) arrays of x86 long double have
holes due to alignment padding, but this wasn't being spotted
by HasStructPadding (renamed to HasPadding).  The same goes
for arrays of oddly sized ints.  Vectors also suffer from this,
in fact the problem for vectors is much worse because basic
vector assumptions seem to be broken by vectors of type with
alignment padding.   I didn't try to fix any of these vector
problems.  (2) The code for extracting smaller integers from
larger ones (in the "int union" case) was wrong on big-endian
machines for integers with size not a multiple of 8, like i1.
Probably this is impossible to hit via llvm-gcc, but I fixed
it anyway while there and added a testcase.  I also got rid of
some trailing whitespace and changed a function name which
had an obvious typo in it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43672 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-04 14:43:57 +00:00
Owen Anderson
7ebba512c3 Fix test/Transforms/DeadStoreElimination/PartialStore.ll, which had been
silently failing because of an incorrect run line for some time.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43605 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 05:29:16 +00:00