Commit Graph

4485 Commits

Author SHA1 Message Date
Matthijs Kooijman
d1d1de7f39 Revert r53606. It turns out that explicitely tracking the liveness of the
return value as a whole in deadargelim is really not needed now that we simply
rebuild the old return value and actually prevents some canonicalization from
taking place.

This revert stops deadargelim from changing {i32} into i32 for now, but I'll
fix that next.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53609 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 14:39:36 +00:00
Matthijs Kooijman
eb32b453b3 Make deadargelim a bit less smart, so it doesn't choke on nested structs as
return values that are still (partially) live. Instead of updating all uses of
a call instruction after removing some elements, it now just rebuilds the
original struct (With undef gaps where the unused values were) and leaves it to
instcombine to clean this up.

The added testcase still fails currently, but this is due to instcombine which
isn't good enough yet. I will fix that part next.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53608 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 14:03:10 +00:00
Matthijs Kooijman
9c9418d0f3 Don't use isa when we can reuse a previous dyn_cast.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53607 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 13:39:08 +00:00
Matthijs Kooijman
ddd1a79b6d Make DeadArgElim keep liveness of the return value as a whole in addition to
only the liveness of partial return values (for functions returning a struct).
This is more explicit to prevent unwanted changes in the return value. 

In particular, deadargelim now canonicalizes a function returning {i32} to
returning i32 and {} to void, if the struct returned is not used in its
entirety, but only the single element is used.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53606 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 13:36:06 +00:00
Matthijs Kooijman
2bf5372d8a Let DAE keep a list of live functions, instead of simply marking all arguments
and return values live for those functions. This doesn't change anything yet,
but prepares for the coming commits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53601 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 09:11:16 +00:00
Matthijs Kooijman
3015652473 Split DAE::MarkLive into MarkLive and PropagateLiveness.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53600 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 09:00:17 +00:00
Matthijs Kooijman
6cdd54b6f7 Pass around const RetOrArg references instead of copying values. Also, mark
RetOrArg::getDescription() as const.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53599 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 08:56:49 +00:00
Matthijs Kooijman
03016ca361 Simplify debug code by using RetOrArg::getDescription().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53598 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 08:53:36 +00:00
Matthijs Kooijman
0d1730a14c Fix indentation (intentionally left out of the previous commit).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53592 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 08:47:32 +00:00
Matthijs Kooijman
a3ec5d6ecc Move the deadargelim code for intrinsically alive functions into its own
method, to slightly simplify control flow.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53591 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 08:45:12 +00:00
Dan Gohman
3fea643fb4 Fix uninitialized use of the Changed variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53564 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14 17:55:01 +00:00
Chris Lattner
46868c07bb Reapply r53540, now with the matching header!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53557 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14 17:32:59 +00:00
Duncan Sands
91e1c32dd0 Revert r53540 - it does not compile.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53549 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14 07:59:28 +00:00
Chris Lattner
ac77bfdbd4 If a function calls setjmp, never inline it into other functions. This is
a hack around the fact that we don't represent the CFG correctly for sj/lj.
It fixes PR2486.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53540 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14 00:46:56 +00:00
Chris Lattner
4238453135 simplify some code, shuffle and insertelt always return a vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53538 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14 00:32:20 +00:00
Chris Lattner
fdb19e5887 Fix PR2506 by being a bit more careful about reverse fact propagation when
disproving a condition.  This actually compiles the existing testcase
(udiv_select_to_select_shift) to:

define i64 @test(i64 %X, i1 %Cond) {
entry:
	%divisor1.t = lshr i64 %X, 3		; <i64> [#uses=1]
	%quotient2 = lshr i64 %X, 3		; <i64> [#uses=1]
	%sum = add i64 %divisor1.t, %quotient2		; <i64> [#uses=1]
	ret i64 %sum
}

instead of:

define i64 @test(i64 %X, i1 %Cond) {
entry:
	%quotient1.v = select i1 %Cond, i64 3, i64 4		; <i64> [#uses=1]
	%quotient1 = lshr i64 %X, %quotient1.v		; <i64> [#uses=1]
	%quotient2 = lshr i64 %X, 3		; <i64> [#uses=1]
	%sum = add i64 %quotient1, %quotient2		; <i64> [#uses=1]
	ret i64 %sum
}



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53534 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14 00:15:52 +00:00
Chris Lattner
093a438502 Fix mishandling of the infinite loop case when merging two blocks. This
fixes PR2540.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53533 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-13 22:23:11 +00:00
Chris Lattner
b824512b8d more refactoring. Use early exits instead of really complex logic.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53532 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-13 22:04:41 +00:00
Chris Lattner
eb388af89f improve comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53531 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-13 21:55:46 +00:00
Chris Lattner
867661ac8b factor another large hunk of code out into its own function.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53530 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-13 21:53:26 +00:00
Chris Lattner
3698909623 Final bit of simplification for FoldBranchToCommonDest.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53528 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-13 21:20:19 +00:00
Chris Lattner
70087f31f1 simplify logic a bit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53527 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-13 21:15:11 +00:00
Chris Lattner
1347e87c7b Refactor some code out into its own helper function, getting rid of crazy multiline
conditionals and commenting the code better.

No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53526 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-13 21:12:01 +00:00
Nick Lewycky
3ac9e109b2 Enhance analysis of srem.
Remove dead code analyzing urem. 'urem' of power-of-2 is canonicalized to an
'and' instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53506 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-12 05:04:38 +00:00
Dan Gohman
c418bf3dd5 Use find instead of lower_bound.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53474 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 20:58:19 +00:00
Owen Anderson
c45996bf74 Don't call lookupNumber more than we have to.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53470 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 20:05:13 +00:00
Nick Lewycky
7d9843fc37 Document 'mask' in this calculation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53454 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 08:16:26 +00:00
Nick Lewycky
1f26c188f8 Remove misleading constant from comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53452 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 07:36:19 +00:00
Nick Lewycky
4bf1e59819 Add another optimization from PR2330. Also catch some missing cases that are
similar.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53451 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 07:20:53 +00:00
Chris Lattner
d01bee7170 a missed optimization that Eli spotted
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53449 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 06:40:29 +00:00
Chris Lattner
f9685ac68e another bug in the same line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53448 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 06:38:16 +00:00
Chris Lattner
a8ff4a88bb fix a bug spotted by Eli's eagle eyes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53447 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 06:36:01 +00:00
Chris Lattner
183661e43a simplify and merge a bunch of code. Instead of comparing against
the min/max values for an integer type, compare against the min/max
values we can prove contain the input.  This might be a tighter bound,
so this is general goodness.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53446 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 05:40:05 +00:00
Chris Lattner
84dff672a4 fold away (x <= cst) earlier, allowing us to not have to
handle them in some code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53445 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 05:08:55 +00:00
Chris Lattner
85b5eb0505 Fix folding of icmp's of i1 where the comparison is signed. The code
was using the algorithm for folding unsigned comparisons which is
completely wrong.  This has been broken since the signless types change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53444 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 04:20:58 +00:00
Chris Lattner
f299184565 Fix a bogus optimization: folding (slt (zext i1 A to i32), 1) -> (slt i1 A, true)
This cause a regression in InstCombine/JavaCompare, which was doing the right
thing on accident.  To handle the missed case, generalize the comparisons based
on masked bits a little bit to handle comparisons against the max value. For 
example, we can now xform (slt i32 (and X, 4), 4) -> (setne i32 (and X, 4), 4)




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53443 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 04:09:09 +00:00
Matthijs Kooijman
d16918f843 Restructure dead argument elimination, try #3 :-)
Rewrite the DeadArgumentElimination pass, to use a more explicit tracking of
dependencies between return values and/or arguments. Also make the handling of
arguments and return values the same.

The pass now looks properly inside returned structs, but only at the first
level (ie, not inside nested structs).

This version fixed a few more bugs and was cleaned up a bit. It now passes all
of LLVM's testing, and should still pass SPEC2006. There is still a minor bug
with regard to returning nested structs. Since there is currently nothing that
emits such IR, I will fix that in a seperate commit (partly because it requires
a non-trivial fix).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53400 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-10 10:24:08 +00:00
Nick Lewycky
5dcc41f5b3 Fix overzealous optimization. Thanks to Duncan Sands for pointing out my error!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53393 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-10 05:51:40 +00:00
Nick Lewycky
d8ad492238 Simplify, suggested by Chris Lattner.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53283 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-09 07:35:26 +00:00
Nick Lewycky
9ee863ecc0 Fold (a < 8) && (b < 8) into (a|b) < 8 for unsigned less or greater than.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53282 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-09 07:29:11 +00:00
Nick Lewycky
d1f77bf931 Fold ((1 << a) & 1) to (a == 0).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53276 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-09 05:20:13 +00:00
Nick Lewycky
b4d1bc989e Reduce x - y to -y when we know the 'x' part will get masked off anyways.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53271 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-09 04:32:37 +00:00
Devang Patel
a5e27f8028 If loop induction variable's start value is less then its exit value then do not split the loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53265 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-09 00:12:01 +00:00
Chris Lattner
710429645a Fix PR2496, a really nasty bug which involved sinking volatile loads
into phis.  This is actually the same bug as PR2262 /
2008-04-29-VolatileLoadDontMerge.ll, but I missed checking the first 
predecessor for multiple successors.  Testcase here:
InstCombine/2008-07-08-VolatileLoadMerge.ll



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53240 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-08 17:18:32 +00:00
Evan Cheng
1ce75dcbbc Fix two serious LSR bugs.
1. LSR runOnLoop is always returning false regardless if any transformation is made.
2. AddUsersIfInteresting can create new instructions that are added to DeadInsts. But there is a later early exit which prevents them from being freed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53193 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-07 19:51:32 +00:00
Dan Gohman
6b345ee9b2 Make DenseMap's insert return a pair, to more closely resemble std::map.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53177 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-07 17:46:23 +00:00
Nick Lewycky
b8cd6a49b5 Fix missed optimization opportunity when analyzing cast of mul and select.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53151 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-05 21:19:34 +00:00
Owen Anderson
0ae33ef202 Use information already present in the ValueTable to fast-fail when we know there won't be a value number match. This speeds up GVN on a case where there are very few redundancies by ~25%.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53108 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 17:44:33 +00:00
Devang Patel
77a01136ff Do not try to update dominator info while manipulating CFG. This code does not handle all cases and keeps invalid dom info around some cases, which misleads other passes down stream.
Right now, dom info is recaluclated in the end if the loop is switched.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53106 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 17:37:52 +00:00
Owen Anderson
9da02b844f Remove the ability for ADCE to remove unreachable blocks in loop nests, because, as Eli pointed out, SimplifyCFG already does this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53104 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 17:21:41 +00:00
Bill Wendling
38976dc394 Remove unused function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53090 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 07:10:03 +00:00
Devang Patel
98260a474c Preserve dom info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53089 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 07:04:22 +00:00
Devang Patel
f31b3bbd10 Remove extra FIXME
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53087 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 06:50:04 +00:00
Devang Patel
4be7d294f8 Reconstruct dom info, if loop is unswitched.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53086 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 06:48:21 +00:00
Devang Patel
b76247b8b1 LoopUnswitch does not preserve dominator info in all cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53085 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 05:55:03 +00:00
Devang Patel
825cb98d9a Undo previous patch. It is not that simple to fix dom info here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53062 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 00:08:13 +00:00
Devang Patel
501e763dfe Preserve dom info while simplifing loop after the unswitch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53052 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-02 22:58:54 +00:00
Owen Anderson
ea6462bfd0 Use df_ext_iterator to capture the reachable set without allocating an extra set.
Also, move large sets and vectors out of instance variables and onto the stack,
and give them more reasonable sizes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53044 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-02 18:41:09 +00:00
Owen Anderson
cb29a4f66a Avoid a redundant call.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53040 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-02 18:15:31 +00:00
Owen Anderson
77d76b7ef7 Add support to ADCE for pruning unreachable blocks. This addresses the final
part of PR2509.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53038 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-02 18:05:19 +00:00
Owen Anderson
2c04b0da2b Use DenseSet rather than SmallPtrSet for the alive set. Using SmallPtrSet
with a huge "size" parameter is actually quite inefficient.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53034 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-02 17:32:04 +00:00
Owen Anderson
f2aa160b35 A better fix for PR2503 that doesn't pessimize GVN in the presence of unreachable blocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53032 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-02 17:20:16 +00:00
Devang Patel
1e41f6d724 reuse vectors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53007 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-02 01:44:29 +00:00
Devang Patel
2095c38c7a Fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53006 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-02 01:31:19 +00:00
Devang Patel
e6962dfb64 Preserve loop data so that it is not fetched everytime it is needed.
Keep track of currentLoop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53005 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-02 01:18:13 +00:00
Evan Cheng
0ff39b3feb - Re-apply 52748 and friends with fix. GetConstantStringInfo() returns an empty string for ConstantAggregateZero case which surprises selectiondag.
- Correctly handle memcpy from constant string which is zero-initialized.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52891 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-30 07:31:25 +00:00
Anton Korobeynikov
6d116bc7ce Revert (52748 and friends):
Move GetConstantStringInfo to lib/Analysis. Remove
string output routine from Constant. Update all
callers. Change debug intrinsic api slightly to
accomodate move of routine, these now return values
instead of strings.

This unbreaks llvm-gcc bootstrap.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52884 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-29 17:57:03 +00:00
Eric Christopher
872a738775 Remove unused function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52749 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 01:19:35 +00:00
Eric Christopher
0d2b0aba42 Move GetConstantStringInfo to lib/Analysis. Remove
string output routine from Constant. Update all
callers. Change debug intrinsic api slightly to
accomodate move of routine, these now return values
instead of strings.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52748 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 00:31:12 +00:00
Evan Cheng
890aaa8710 Restore DeadArgElim back to 52570. It's breaking 447.dealII.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52736 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-25 18:10:09 +00:00
Duncan Sands
b58d211dbb Pacify gcc-4.3.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52723 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-25 16:31:18 +00:00
Matthijs Kooijman
ea9e516e86 Fix a (false) warning on darwin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52705 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-25 08:12:16 +00:00
Matthijs Kooijman
177058b4bd Fix some cosmetics in comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52704 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-25 08:10:21 +00:00
Evan Cheng
e5334ea518 - Use O(1) check of basic block size limit.
- Avoid speculatively execute vector ops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52703 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-25 07:50:12 +00:00
Chris Lattner
aa0bf52625 Fix PR2488, a case where we deleted stack restores too aggressively.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52702 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-25 05:59:28 +00:00
Dan Gohman
8dbe7f832e Revert 52645, the loop unroller changes. It caused a regression in 252.eon.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52688 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-24 20:44:42 +00:00
Dan Gohman
2864ce6065 Fix a typo in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52687 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-24 18:00:21 +00:00
Matthijs Kooijman
1d9a277761 Commit the new DeadArgElim pass again, this time with the gcc bootstrap failures fixed.
Also add a testcase to reproduce the gcc bootstrap failure in very much reduced form.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52677 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-24 16:30:26 +00:00
Matthijs Kooijman
4e78908b94 Rename a few variables to be more consistent.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52672 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-24 09:14:10 +00:00
Dan Gohman
cb41e6bf52 Use use_empty() instead of getNumUses(), avoiding a use list traversal.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52651 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-23 23:23:49 +00:00
Dan Gohman
73b43b9b54 Fix spelling and grammar in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52648 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-23 22:11:52 +00:00
Dan Gohman
55e283c71e Revamp the loop unroller, extending it to correctly update PHI nodes
in the presence of out-of-loop users of in-loop values and the trip
count is not a known multiple of the unroll count, and to be a bit
simpler overall. This fixes PR2253.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52645 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-23 21:29:41 +00:00
Evan Cheng
2e9f0b1a32 Disable PRE. It's breaking bootstrapping.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52643 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-23 21:22:35 +00:00
Owen Anderson
b70a571c99 Tighten the conditions under which we do PRE, remove some unneeded code, and correct our preserved analyses list, since we
do now change the CFG by splitting critical edges during PRE.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52631 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-23 17:49:45 +00:00
Chris Lattner
2a6a645709 minor tidying of comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52630 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-23 17:11:23 +00:00
Owen Anderson
ae18bd4246 At Chris' suggestion, move the liveness and worklist datastructures into
instance variables so they can be allocated just once, and reuse the worklist
as the dead list as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52618 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-23 06:13:12 +00:00
Dan Gohman
cbfe5bbe88 Improve LSR's dead-phi detection to handle use-def cycles
with more than two nodes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52617 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-22 20:44:02 +00:00
Dan Gohman
9b78763fce Use Loop::block_iterator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52616 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-22 20:18:58 +00:00
Chris Lattner
963a97f1a3 Fix PR2369 by making scalarrepl more careful about promoting
structures.  Its default threshold is to promote things that are
smaller than 128 bytes, which is sane.  However, it is not sane
to do this for things that turn into 128 *registers*.  Add a cap
on the number of registers introduced, defaulting to 128/4=32.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52611 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-22 17:46:21 +00:00
Eli Friedman
5c1f172213 Fix for PR2479: correctly optimize expressions like (a > 13) & (a ==
15).

See also PR1800, which is about the signed case.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52608 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 23:36:13 +00:00
Dan Gohman
1adec83ae8 Use Instruction::eraseFromParent().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52606 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 22:08:46 +00:00
Chris Lattner
629c1a3f78 Fix warning when assertions disabled.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52590 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 19:49:01 +00:00
Evan Cheng
4ce138cc55 Enable PRE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52574 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 07:26:53 +00:00
Evan Cheng
9f99b7c595 Back out Matthijs' DAE patches. It's miscompiling gcc driver.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52570 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 00:31:44 +00:00
Dan Gohman
9614fcc640 Clean up a use of std::distance.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52544 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 17:11:32 +00:00
Dan Gohman
60ea268645 Tidy up some commments and use the getAggregateOperand and
getInsertedValueOperand accessors. Thanks Matthijs!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52543 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 16:41:17 +00:00
Dan Gohman
dfaceb49fc Fix the conditions under which SCCP should examine insertvalue
instructions. Thanks to Matthijs Kooijman for pointing this out!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52542 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 16:39:44 +00:00
Matthijs Kooijman
7e43b3be88 80 column and trailing whitespace fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52539 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 15:34:07 +00:00
Matthijs Kooijman
df0891d2ff Don't let DeadArgumentElimination attempt to update callers when the return
type wasn't changed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52538 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 15:25:43 +00:00
Matthijs Kooijman
03d18569cb Don't let DeadArgElimination change the return type ({} into void and {T}
into T) when no return values are actually dead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52537 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 15:16:45 +00:00
Matthijs Kooijman
9cb6ec26b3 Explicitely track if any arguments or return values were removed in
DeadArgumentElimination and assert that the function type does not change if
nothing was changed. This should catch subtle changes in function type that are
not intended.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52536 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 14:28:52 +00:00
Matthijs Kooijman
1b492b2f8d Remove debug output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52535 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 14:03:35 +00:00
Matthijs Kooijman
c95e44b4e0 Recommit r52459, rewriting of the dead argument elimination pass.
This is a fixed version that no longer uses multimap::equal_range, which
resulted in a pointer invalidation problem.

Also, DAE::InspectedFunctions was not really necessary, so it got removed.

Lastly, this version no longer applies the extra arg hack on functions who did
not have any arguments to start with.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52532 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 09:36:16 +00:00
Owen Anderson
f2204d7bb1 Really disable PRE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52531 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 08:59:13 +00:00
Chris Lattner
2de3fec61c Fix PR2471, which is a bug involving an invalid promotion from a conditional load.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52525 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 05:12:56 +00:00
Owen Anderson
6fafe847b2 Change around the data structures used to store availability sets, resulting in a GVN+PRE that is faster that GVN alone was before.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52521 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 01:15:47 +00:00
Dan Gohman
c4b65ea56b Teach SCCP about insertvalue and extractvalue, and about
propagating constants across aggregate return values when
insertvalue and extractvalue are used.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52520 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 01:15:44 +00:00
Dan Gohman
2c31750cd0 Teach InlineFunction how to differentiate between multiple-value
return statements and aggregate returns so that it handles both
correctly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52519 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 01:03:44 +00:00
Evan Cheng
88d11c03cd Disable PRE for now. It seems to be breaking llvm-gcc bootstrapping.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52518 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 01:01:07 +00:00
Owen Anderson
aa0b63422a Add a hidden -disable-pre flag for testing purposes. This should be removed
once benchmarking is completed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52506 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-19 19:57:25 +00:00
Owen Anderson
5c274eebc6 PRE requires that critical edges be split.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52505 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-19 19:54:19 +00:00
Bill Wendling
ac151da204 Remove dead code causing a warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52502 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-19 18:00:44 +00:00
Dan Gohman
52d36e6f87 Use the common API for adding instructions to basic blocks instead of
using BasicBlock::getInstList.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52500 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-19 17:53:32 +00:00
Owen Anderson
9da52dce89 Be sure to remove values from the value numbering table after we delete them.
This fixes a failure on povray.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52499 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-19 17:53:26 +00:00
Dan Gohman
d02d917c72 Use Instruction::moveBefore instead of manipulating the instruction list
directly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52498 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-19 17:47:47 +00:00
Dan Gohman
610c0e2b40 Avoid using BasicBlock::getInstList directly in a few places.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52497 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-19 17:37:25 +00:00
Owen Anderson
3cd8eb314a Revert support for insertvalue and extractvalue instructions for the moment.
GVN expects that all inputs which to an instruction fall somewhere in the value
hierarchy, which isn't true for these.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52496 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-19 17:25:39 +00:00
Dan Gohman
f3dc70092c Delete dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52494 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-19 17:18:39 +00:00
Matthijs Kooijman
f0da2039d1 Use a CallSite to find the nth argument of a call/invoke instruction instead of
using getOperand() directly. This makes things work with invoke instructions as
well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52489 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-19 08:53:24 +00:00
Owen Anderson
d34ac6e782 Add support for extractvalue and insertvalue instructions in GVN.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52472 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 21:59:00 +00:00
Owen Anderson
b230372437 Add local PRE to GVN. This only operates in cases where it would not increase code size, namely when the instantiated expression
would only need to be created in one predecessor.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52471 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 21:41:49 +00:00
Chris Lattner
6c3bfba06e Fix the regressions on sext-misc.ll my patch yesterday caused.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52466 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 18:11:55 +00:00
Owen Anderson
bb3761c9e5 Revert r52459, which was causing an infinite loop or massive slowdown on MultiSource/Applications/SPASS, and possibly others as well.
Please reapply once this is fixed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52465 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 17:32:16 +00:00
Dan Gohman
cfeb6a4506 Move LSR's private isZero function to a public SCEV member
function, and make use of it in several places.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52463 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 16:23:07 +00:00
Matthijs Kooijman
ca85d65277 Rewrite the DeadArgumentElimination pass, to use a more explicit tracking of
dependencies between return values and/or arguments. Also make the handling of
arguments and return values the same.

The pass now looks properly inside returned structs, but only at the first                                                                                     
level (ie, not inside nested structs).

Also add a testcase for testing various variations of (multiple) dead rerturn
values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52459 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 11:12:53 +00:00
Matthijs Kooijman
c2afe89019 Reapply r52397 (make IPConstProp promote returned arguments), but fixed this
time. Sorry for the trouble!

This time, also add a testcase, which I should have done in the first place...


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52455 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 08:30:37 +00:00
Matthijs Kooijman
8b0fcf38ef Reapply r52396, it was unrelated to the breakage (that was caused by r52397, my
commit after this).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52453 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 08:09:27 +00:00
Chris Lattner
0521e3cdc1 implement some simple bswap optimizations, rdar://5992453
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52442 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 04:33:20 +00:00
Chris Lattner
8114b718c9 make truncate/sext elimination capable of changing phi's. This
implements rdar://6013816 and the testcase in Transforms/InstCombine/sext-misc.ll.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52440 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 04:00:49 +00:00
Devang Patel
64cd658223 Preserve dominance frontier while trivially unswitching loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52438 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 02:16:38 +00:00
Owen Anderson
2960ed4b85 We don't want to find dependencies within the same block in this case. It leads to incorrect results because
we're detecting something at or after the call we're querying on.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52433 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-17 22:27:06 +00:00
Chris Lattner
fc329f4fa1 revert recent patch which is causing widespread breakage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52415 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-17 17:06:43 +00:00
Duncan Sands
34b176a181 Fix typo that changed the logic to something wrong.
Spotted by Nick Lewycky.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52411 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-17 15:55:30 +00:00
Matthijs Kooijman
2fbabf6e6d Learn IPConstProp to propagate arguments that are directly returned. Strictly
speaking these are not constant values. However, when a function always returns
one of its arguments, then from the point of view of each caller the return
value is constant (or at least a known value) and can be replaced.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52397 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-17 12:20:24 +00:00
Matthijs Kooijman
906e423724 Learn IPConstProp to look at individual return values and propagate them
individually.

Also learn IPConstProp how returning first class aggregates work, in addition
to old style multiple return instructions.

Modify the return-constants testscase to confirm this behaviour.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52396 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-17 12:02:52 +00:00
Dan Gohman
9b93dd1f1a Refine the change in r52258 for avoiding use-before-def conditions
when changing the stride of a comparison so that it's slightly
more precise, by having it scan the instruction list to determine
if there is a use of the condition after the point where the
condition will be inserted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52371 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-16 22:34:15 +00:00
Evan Cheng
72b7b098c7 Switch over to SetVector to ensure same order of iterations do not vary across runs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52361 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-16 21:08:17 +00:00
Evan Cheng
69d5053f9c Iterating over SmallPtrSet is not deterministic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52339 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-16 18:17:09 +00:00
Matthijs Kooijman
0a7413dad8 Pass around Instruction* instead of Instruction& in FindInsertedValue and friends.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52318 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-16 13:13:08 +00:00
Matthijs Kooijman
710eb236e6 80 column fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52316 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-16 12:57:37 +00:00
Matthijs Kooijman
b23d5adbc8 Move FindScalarValue from InstructionCombining.cpp to ValueTracking.cpp. While
I'm at it, rename it to FindInsertedValue.

The only functional change is that newly created instructions are no longer
added to instcombine's worklist, but that is not really necessary anyway (and
I'll commit some improvements next that will completely remove the need).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52315 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-16 12:48:21 +00:00
Chris Lattner
077707ccc0 Fix the crash on SimplifyLibCalls/2005-05-20-sprintf-crash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52295 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-16 04:10:21 +00:00
Chris Lattner
c5dc660ea0 Fix a case where tailcallelim wouldn't set the changed bit when it made a change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52267 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-14 00:49:48 +00:00
Eli Friedman
6903a24f32 Don't skip over instructions other than loads that might read memory
when trying to sink stores.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52259 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-13 22:02:12 +00:00
Dan Gohman
e562b1725e Protect ChangeCompareStride from situations in which it is possible
for it to generate use-before-def IR, such as in this testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52258 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-13 21:43:41 +00:00
Eli Friedman
66fe80aa57 Make sure SimplifyStoreAtEndOfBlock doesn't mess with loops; the
structure checks are incorrect if the blocks aren't distinct.
Fixes PR2435.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52257 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-13 21:17:49 +00:00
Wojciech Matyjewicz
900872186d Use recently added getTruncateOrZeroExtend method to make the code shorter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52251 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-13 17:02:03 +00:00
Gabor Greif
52ed363fd3 fix a minor deviation from the original in my previous commit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52247 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-12 21:51:29 +00:00
Gabor Greif
177dd3ff11 op_iterator-ify some loops, low hanging fruit only, there is more
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52246 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-12 21:37:33 +00:00
Evan Cheng
502a4f5162 Do not speculatively execute an instruction by hoisting it to its predecessor BB if any of its operands are defined but not used in BB. The transformation will prevent the operand from being sunk into the use block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52244 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-12 21:15:59 +00:00
Evan Cheng
0d0ca8572f Revert 52223.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52243 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-12 20:55:39 +00:00
Owen Anderson
af4240ac2d Switch GVN to use ScopedHashTable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52242 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-12 19:25:32 +00:00
Gabor Greif
6725cb5f1c op_iterator-ify some loops, fix 80col violations
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52226 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-11 21:38:51 +00:00
Evan Cheng
797d95188d For now, avoid generating FP select instructions in order to speculatively execute integer arithmetic instructions. FP selects are more likely to be expensive (even compared to branch on fcmp). This is not a wonderful solution but I rather err on the side of conservative.
This fixes the heapsort performance regressions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52224 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-11 19:18:20 +00:00
Evan Cheng
bb318c073e Avoid duplicating loop header which leads to unnatural loops (and just seem like general badness to me, likely to cause code explosion).
Patch by Florian Brandner.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52223 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-11 19:07:54 +00:00
Matthijs Kooijman
a9012eca1a Teach instruction combining about the extractvalue. It can succesfully fold
useless insert-extract chains, similar to how it folds them for vectors.

Add a testcase for this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52217 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-11 14:05:05 +00:00
Matthijs Kooijman
b4d6a5a76c Clarify a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52212 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-11 09:00:12 +00:00
Gabor Greif
f7ea3638e0 op_iterator-ify loops
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52191 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-10 22:03:26 +00:00
Chris Lattner
313f0e63f7 lower calls to abs to inline code, PR2337
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52138 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-09 08:26:51 +00:00
Chris Lattner
18d73c206e Fix PR2411, where ip constant prop would propagate the
result of a weak function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52137 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-09 07:58:07 +00:00
Duncan Sands
8e4eb09b1e Remove comparison methods for MVT. The main cause
of apint codegen failure is the DAG combiner doing
the wrong thing because it was comparing MVT's using
< rather than comparing the number of bits.  Removing
the < method makes this mistake impossible to commit.
Instead, add helper methods for comparing bits and use
them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52098 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-08 20:54:56 +00:00
Chris Lattner
7d8ab4efbc Limit the icmp+phi merging optimization to the cases where it is profitable:
don't make i1 phis when it won't be possible to eliminate them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52097 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-08 20:52:11 +00:00
Evan Cheng
4d09efd7b8 Speculatively execute a block when the the block is the then part of a triangle shape and it contains a single, side effect free, cheap instruction. The branch is eliminated by adding a select instruction. i.e.
Turn                                                                                                                                                                                                       
BB:                                                                                                                                                                                                        
    %t1 = icmp                                                                                                                                                                                             
    br i1 %t1, label %BB1, label %BB2                                                                                                                                                                      
BB1:                                                                                                                                                                                                       
    %t3 = add %t2, c                                                                                                                                                                                       
    br label BB2                                                                                                                                                                                           
BB2:                                                                                                                                                                                                       
=>                                                                                                                                                                                                         
BB:                                                                                                                                                                                                        
    %t1 = icmp                                                                                                                                                                                             
    %t4 = add %t2, c                                                                                                                                                                                       
    %t3 = select i1 %t1, %t2, %t3


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52073 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-07 08:52:29 +00:00
Devang Patel
4c37c07ee3 LoopSimplify preserves AA.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52053 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-06 17:50:58 +00:00
Duncan Sands
83ec4b6711 Wrap MVT::ValueType in a struct to get type safety
and better control the abstraction.  Rename the type
to MVT.  To update out-of-tree patches, the main
thing to do is to rename MVT::ValueType to MVT, and
rewrite expressions like MVT::getSizeInBits(VT) in
the form VT.getSizeInBits().  Use VT.getSimpleVT()
to extract a MVT::SimpleValueType for use in switch
statements (you will get an assert failure if VT is
an extended value type - these shouldn't exist after
type legalization).
This results in a small speedup of codegen and no
new testsuite failures (x86-64 linux).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52044 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-06 12:08:01 +00:00
Zhou Sheng
cc41940dff As Chris suggested, handle the situation if ShAmt larger than BitWidth,
otherwise, opt might crash.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52041 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-06 08:32:05 +00:00
Zhou Sheng
17183ab973 If BitWidth equals to ShtAmt, the RHSKnownZero[BitWidth-ShiftAmt-1] will
crash the opt. Just fix this.

Test case in llvm/test/Transforms/InstCombine/2008-06-05-ashr-crash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52003 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 14:23:44 +00:00
Matthijs Kooijman
02518140ac Learn ScalarReplAggregrates how stores and loads of first class aggregrates
work and how to replace them into individual values. Also, when trying to
replace an aggregrate that is used by load or store with a single (large)
integer, don't crash (but don't replace the aggregrate either).

Also adds a testcase for both structs and arrays.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51997 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 12:51:53 +00:00
Matthijs Kooijman
47c6fd7317 Let StructRetPromotion check if all if its users are really calls or invokesn,
not other instructions. This fixes a crash with the added testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51992 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 08:57:20 +00:00
Matthijs Kooijman
257da0a7fc Let StructRetPromotion check if it's users are really calling it and not
passing its pointer. Fixes test with added testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51991 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 08:48:32 +00:00
Matthijs Kooijman
41335411a8 Use use_iterator::getOperandNo instead of CallSite::hasArgument to check if a
function is passed as an argument instead of called. Also do this check a bit
earlier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51990 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 08:34:25 +00:00
Matthijs Kooijman
845f524c25 Update comments and documentation to reflect that GCSE and ValueNumbering are
deprecated by the GVN and GVNPRE passes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51983 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 07:55:49 +00:00
Owen Anderson
10a05bfff0 Remove unneeded #include.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51955 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-04 18:28:10 +00:00
Matthijs Kooijman
227c27dd06 Replace two manual loops with calls to CallSite::hasArguments (no functional changes).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51947 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-04 16:57:50 +00:00
Duncan Sands
a0fcc08e65 Change packed struct layout so that field sizes
are the same as in unpacked structs, only field
positions differ.  This only matters for structs
containing x86 long double or an apint; it may
cause backwards compatibility problems if someone
has bitcode containing a packed struct with a
field of one of those types.
The issue is that only 10 bytes are needed to
hold an x86 long double: the store size is 10
bytes, but the ABI size is 12 or 16 bytes (linux/
darwin) which comes from rounding the store size
up by the alignment.  Because it seemed silly not
to pack an x86 long double into 10 bytes in a
packed struct, this is what was done.  I now
think this was a mistake.  Reserving the ABI size
for an x86 long double field even in a packed
struct makes things more uniform: the ABI size is
now always used when reserving space for a type.
This means that developers are less likely to
make mistakes.  It also makes life easier for the
CBE which otherwise could not represent all LLVM
packed structs (PR2402).
Front-end people might need to adjust the way
they create LLVM structs - see following change
to llvm-gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51928 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-04 08:21:45 +00:00
Owen Anderson
269db29bdb LoopIndexSplit can sometimes result in cases where a block in its own domfrontier.
Don't crash when we encounter one of these.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51915 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-03 18:29:48 +00:00
Dan Gohman
c702a9ed1c Fix whitespace in whitespace-significant pseudocode in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51890 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-03 00:57:21 +00:00
Devang Patel
2f170997b5 Update dom tree. Fix PR 2372.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51887 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-02 22:52:56 +00:00
Chris Lattner
833f25d79e move CannotBeNegativeZero to ValueTracking. Simplify some signbit comparisons.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51864 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-02 01:29:46 +00:00
Chris Lattner
173234a68f move ComputeMaskedBits, MaskedValueIsZero, and ComputeNumSignBits
out of instcombine into a new file in libanalysis.  This also teaches
ComputeNumSignBits about the number of sign bits in a constantint.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51863 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-02 01:18:21 +00:00
Owen Anderson
009e4f7609 Fix two issues that Eli Friedman pointed out, where would misoptimized code like:
char a[200];
init(a, a+200);

OR

int a[200];
char* b = (char*)a;
char* c = (char*)a;
foo(b, c);


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51850 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-01 22:26:26 +00:00
Owen Anderson
12cb36c115 Don't remove the memcpy when call slot substitution fails.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51848 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-01 21:52:16 +00:00
Duncan Sands
f413cdfb0b When simplifying a call to a bitcast function, tighten up
the conditions for performing the transform when only the
function declaration is available: no longer allow turning
i32 into i64 for example.  Only allow changing between
pointer types, and between pointer types and integers of
the same size.  For return values ptr -> intptr was already
allowed; I added ptr -> ptr and intptr -> ptr while there.
As shown by a recent objc testcase, changing the way
parameters/return values are passed can be fatal when calling
code written in assembler that directly manipulates call
arguments and return values unless the transform has no
impact on the way they are passed at the codegen level.
While it is possible to imagine an ABI that treats integers
of pointer size differently to pointers, I don't think LLVM
supports any so the transform should now be safe while still
being useful.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51834 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-01 07:38:42 +00:00
Nick Lewycky
517e1f5cd7 Peer through sext/zext when looking for not(cmp).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51819 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-31 19:01:33 +00:00
Nick Lewycky
9419ddb289 Add more i1 optimizations. add, sub, mul, s/udiv on i1 are now simplified away.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51817 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-31 17:59:52 +00:00
Nick Lewycky
fd12a0b20b Adding i1 is always Xor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51816 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-31 17:10:28 +00:00
Gabor Greif
ba2c487424 rewrite operand loops to use iterators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51789 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-30 21:24:22 +00:00
Owen Anderson
427de86ada Since LCSSA switched over to DenseMap, we have to be more careful to avoid iterator invalidation. Fixes PR2385.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51777 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-30 17:31:01 +00:00
Matthijs Kooijman
494661c623 Use eraseFromParent() instead of doing that manually in two places.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51770 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-30 12:35:46 +00:00
Dan Gohman
b99e2e20b2 const-ify getOpcode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51698 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-29 19:53:46 +00:00
Duncan Sands
a806a87e29 Add a newline at the end of this file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51680 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-29 14:38:23 +00:00
Owen Anderson
038a8746c9 Replace the old ADCE implementation with a new one that more simply solves
the one case that ADCE catches that normal DCE doesn't: non-induction variable
loop computations.

This implementation handles this problem without using postdominators.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51668 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-29 08:45:13 +00:00
Owen Anderson
cd5e6dda7e Remove debugging code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51666 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-29 08:15:48 +00:00
Gabor Greif
5e46321d66 convert more operand loops to iterator formulation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51663 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-29 01:59:18 +00:00
Chris Lattner
a935db8ea2 Implement PR2370: memmove(x,x,size) -> noop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51636 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-28 05:30:41 +00:00
Duncan Sands
43e2a03530 Fix some constructs that gcc-4.4 warns about.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51591 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-27 11:50:51 +00:00
Nick Lewycky
6918a9141e InequalityGraph::node() can create new nodes, invalidating iterators across
the set of nodes. Fix makeEqual to handle this by creating the new node first
then iterating across them second.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51573 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-27 00:59:05 +00:00
Nick Lewycky
70ef629d46 Grammaro.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51572 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-26 22:49:36 +00:00
Duncan Sands
28c3cff825 Factor code to copy global value attributes like
the section or the visibility from one global
value to another: copyAttributesFrom.  This is
particularly useful for duplicating functions:
previously this was done by explicitly copying
each attribute in turn at each place where a
new function was created out of an old one, with
the result that obscure attributes were regularly
forgotten (like the collector or the section).
Hopefully now everything is uniform and nothing
is forgotten.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51567 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-26 19:58:59 +00:00
Owen Anderson
78ecf0d7b1 Use a DenseMap instead of an std::map, speeding up the testcase in PR2368 by about a third.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51565 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-26 10:07:43 +00:00