Commit Graph

390 Commits

Author SHA1 Message Date
Dan Gohman 6deab96c81 Refactor rewriting for PHI nodes into a separate function.
llvm-svn: 96382
2010-02-16 20:25:07 +00:00
Dan Gohman 0849ed5e26 Fix whitespace.
llvm-svn: 96372
2010-02-16 19:42:34 +00:00
Duncan Sands 19d0b47b1f There are two ways of checking for a given type, for example isa<PointerType>(T)
and T->isPointerTy().  Convert most instances of the first form to the second form.
Requested by Chris.

llvm-svn: 96344
2010-02-16 11:11:14 +00:00
Dan Gohman 521efe68ab Split the main for-each-use loop again, this time for GenerateTruncates,
as it also peeks at which registers are being used by other uses. This
makes LSR less sensitive to use-list order.

llvm-svn: 96308
2010-02-16 01:42:53 +00:00
Dan Gohman e4e51a63da Fix whitespace.
llvm-svn: 96179
2010-02-14 18:51:39 +00:00
Dan Gohman e7f74bb16c Fix a comment.
llvm-svn: 96178
2010-02-14 18:51:20 +00:00
Dan Gohman bb7d52213c When complicated expressions are broken down into subexpressions
with multiplication by constants distributed through, occasionally
those subexpressions can include both x and -x. For now, if this
condition is discovered within LSR, just prune such cases away,
as they won't be profitable. This fixes a "zero allocated in a
base register" assertion failure.

llvm-svn: 96177
2010-02-14 18:50:49 +00:00
Dan Gohman 2d0f96d49a Actually, this code doesn't have to be quite so conservative in
the no-TLI case. But it should still default to declining the
transformation.

llvm-svn: 96152
2010-02-14 03:21:49 +00:00
Dan Gohman cb76a806f0 Don't attempt aggressive post-inc uses if TargetLowering is not available,
because profitability can't be sufficiently approximated.

llvm-svn: 96148
2010-02-14 02:45:21 +00:00
John McCall 0daaf13b97 Make LSR not crash if invoked without target lowering info, e.g. if invoked
from opt.

llvm-svn: 96135
2010-02-13 23:40:16 +00:00
Dan Gohman 5b18f039eb Fix a pruning heuristic which implicitly assumed that SmallPtrSet is
deterministically sorted.

llvm-svn: 96071
2010-02-13 02:06:02 +00:00
Dan Gohman 2b75de97c0 Reapply 95979, a compile-time speedup, now that the bug it exposed is fixed.
llvm-svn: 96005
2010-02-12 19:35:25 +00:00
Dan Gohman 363f847ec6 Fix this code to avoid dereferencing an end() iterator in
offset distributions it doesn't expect.

llvm-svn: 96002
2010-02-12 19:20:37 +00:00
Daniel Dunbar e0b2c69d3c Revert "Reverse the order for collecting the parts of an addrec. The order", it
is breaking llvm-gcc bootstrap.

llvm-svn: 95988
2010-02-12 17:27:08 +00:00
Dan Gohman 0194f58047 Reverse the order for collecting the parts of an addrec. The order
doesn't matter, except that ScalarEvolution tends to need less time
to fold the results this way.

llvm-svn: 95979
2010-02-12 11:08:26 +00:00
Dan Gohman 45774ce0ad Reapply the new LoopStrengthReduction code, with compile time and
bug fixes, and with improved heuristics for analyzing foreign-loop
addrecs.

This change also flattens IVUsers, eliminating the stride-oriented
groupings, which makes it easier to work with.

llvm-svn: 95975
2010-02-12 10:34:29 +00:00
Bill Wendling 48816a0b3f Generic reformatting and comment fixing. No functionality change.
llvm-svn: 94771
2010-01-29 00:52:43 +00:00
Bill Wendling 8277838cf8 Add newline to debugging output, and fix some grammar-os in comment.
llvm-svn: 94765
2010-01-29 00:27:39 +00:00
Dan Gohman 045f81981a Revert LoopStrengthReduce.cpp to pre-r94061 for now.
llvm-svn: 94123
2010-01-22 00:46:49 +00:00
Dan Gohman b1ee154b6b When inserting expressions for post-increment users which contain
loop-variant components, adds must be inserted after the increment.
Keep track of the increment position for this case, and insert
these adds in the correct location.

llvm-svn: 94110
2010-01-21 23:01:22 +00:00
Dan Gohman cb8d577eb2 Include IVUsers information in LSR's debug output.
llvm-svn: 94108
2010-01-21 22:46:32 +00:00
Dan Gohman 29916e023d Prune the search for candidate formulae if the number of register
operands exceeds the number of registers used in the initial
solution, as that wouldn't lead to a profitable solution anyway.

llvm-svn: 94107
2010-01-21 22:42:49 +00:00
Dan Gohman c903499ff8 Add a comment.
llvm-svn: 94104
2010-01-21 21:31:09 +00:00
Dan Gohman 51ad99d2c5 Re-implement the main strength-reduction portion of LoopStrengthReduction.
This new version is much more aggressive about doing "full" reduction in
cases where it reduces register pressure, and also more aggressive about
rewriting induction variables to count down (or up) to zero when doing so
reduces register pressure.

It currently uses fairly simplistic algorithms for finding reuse
opportunities, but it introduces a new framework allows it to combine
multiple strategies at once to form hybrid solutions, instead of doing
all full-reduction or all base+index.

llvm-svn: 94061
2010-01-21 02:09:26 +00:00
Dan Gohman b5358003fb Set Changed properly after calling DeleteDeadPHIs.
llvm-svn: 92735
2010-01-05 16:31:45 +00:00
David Greene 2330f78075 Remove dump routine and the associated Debug.h from a header. Patch up
other files to compensate.

llvm-svn: 92075
2009-12-23 22:58:38 +00:00
Dan Gohman 18fa5686f6 Add Loop contains utility methods for testing whether a loop
contains another loop, or an instruction. The loop form is
substantially more efficient on large loops than the typical
code it replaces.

llvm-svn: 91654
2009-12-18 01:24:09 +00:00
Dan Gohman fd7231f1fe Minor code simplification.
llvm-svn: 91653
2009-12-18 01:20:44 +00:00
Dan Gohman b1924e8a0f Don't pass const pointers by reference.
llvm-svn: 91647
2009-12-18 00:38:08 +00:00
Dan Gohman 92c3696524 Reapply LoopStrengthReduce and IVUsers cleanups, excluding the part
of 91296 that caused trouble -- the Processed list needs to be
preserved for the livetime of the pass, as AddUsersIfInteresting
is called from other passes.

llvm-svn: 91641
2009-12-18 00:06:20 +00:00
Evan Cheng 090ac0865a Revert 91280-91283, 91286-91289, 91291, 91293, 91295-91296. It apparently introduced a non-deterministic behavior in the optimizer somewhere.
llvm-svn: 91598
2009-12-17 09:39:49 +00:00
Dan Gohman 265ce318b8 Delete an unused function.
llvm-svn: 91432
2009-12-15 16:30:09 +00:00
Dan Gohman fbeec7270c Fix a thinko; isNotAlreadyContainedIn had a built-in negative, so the
condition was inverted when the code was converted to contains().

llvm-svn: 91295
2009-12-14 17:31:01 +00:00
Dan Gohman 416d5b7361 Remove unnecessary #includes.
llvm-svn: 91293
2009-12-14 17:19:06 +00:00
Dan Gohman 163fb26927 Instead of having a ScalarEvolution pointer member in BasedUser, just pass
the ScalarEvolution pointer into the functions which need it.

llvm-svn: 91289
2009-12-14 17:12:51 +00:00
Dan Gohman 8dbd4e3d16 Don't bother cleaning up if there's nothing to clean up.
llvm-svn: 91288
2009-12-14 17:10:44 +00:00
Dan Gohman 88c7e61c5b Delete an unused variable.
llvm-svn: 91287
2009-12-14 17:08:09 +00:00
Dan Gohman 838f604543 LSR itself doesn't need LoopInfo.
llvm-svn: 91283
2009-12-14 17:02:34 +00:00
Dan Gohman 273e692952 LSR itself doesn't need DominatorTree.
llvm-svn: 91282
2009-12-14 16:57:08 +00:00
Dan Gohman c3513095cf Remove the code in LSR that manually hoists expansions out of loops;
SCEVExpander does this automatically.

llvm-svn: 91281
2009-12-14 16:52:55 +00:00
Dan Gohman ec2a7c58e8 Minor code cleanups.
llvm-svn: 91280
2009-12-14 16:37:29 +00:00
Jim Grosbach 6bf5305f5d grammar
llvm-svn: 89145
2009-11-17 21:37:04 +00:00
Jim Grosbach e4e018ae67 80-column violations
llvm-svn: 89123
2009-11-17 19:05:35 +00:00
Evan Cheng ba4e5da727 Generalize OptimizeLoopTermCond to optimize more loop terminating icmp to use postinc iv.
llvm-svn: 89116
2009-11-17 18:10:11 +00:00
Jim Grosbach 60f4854c76 Remove trailing whitespace
llvm-svn: 89110
2009-11-17 17:53:56 +00:00
Evan Cheng 85a9f430e9 - Teach LSR to avoid changing cmp iv stride if it will create an immediate that
cannot be folded into target cmp instruction.
- Avoid a phase ordering issue where early cmp optimization would prevent the
  later count-to-zero optimization.
- Add missing checks which could cause LSR to reuse stride that does not have
  users.
- Fix a bug in count-to-zero optimization code which failed to find the pre-inc
  iv's phi node.
- Remove, tighten, loosen some incorrect checks disable valid transformations.
- Quite a bit of code clean up.

llvm-svn: 86969
2009-11-12 07:35:05 +00:00
Evan Cheng 12f146d8f7 Block terminator may be a switch.
llvm-svn: 86761
2009-11-11 00:00:21 +00:00
Evan Cheng 87fe40b32d Generalize lsr code that optimize loop to count down towards zero.
llvm-svn: 86715
2009-11-10 21:14:05 +00:00
Dan Gohman a1bf0c0acc Teach LSR to avoid calling SplitCriticalEdge on edges with indirectbr.
llvm-svn: 86193
2009-11-05 23:34:59 +00:00
Dan Gohman a83ac2d9e7 Update various Loop optimization passes to cope with the possibility that
LoopSimplify form may not be available.

llvm-svn: 86175
2009-11-05 21:11:53 +00:00