1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 20:12:56 +02:00
Commit Graph

268 Commits

Author SHA1 Message Date
Dan Gohman
e50a960c5a Fix ScalarEvolution::isLoopGuardedByCond to accept a null Loop*, for
consistency with other routines that use a null Loop* to mean code
not contained by any loop.

llvm-svn: 72008
2009-05-18 16:03:58 +00:00
Dan Gohman
153b5acb45 Minor code cleanups. Do more of the work before the if statements
instead of within their controlling expressions.

llvm-svn: 72007
2009-05-18 15:58:39 +00:00
Dan Gohman
b24fd61296 Add assertion checks to the SCEV operator creation methods to catch
type mismatches.

llvm-svn: 72006
2009-05-18 15:44:58 +00:00
Dan Gohman
2c9bd7e0cb Make ScalarEvolution::isLoopGuardedByCond work even when the edge
entering a loop is a non-split critical edge.

llvm-svn: 72004
2009-05-18 15:36:09 +00:00
Dan Gohman
560da2a066 Add an isOne() utility function to ScalarEvolution, similar to isZero()
and similar to ConstantInt's isOne().

llvm-svn: 72003
2009-05-18 15:22:39 +00:00
Dan Gohman
32cd719eba Add three new helper routines, getNoopOrZeroExtend,
getNoopOrSignExtend, and getTruncateOrNoop. These are similar
to getTruncateOrZeroExtend etc., except that they assert that
the conversion is either not widening or narrowing, as
appropriate. These will be used in some upcoming fixes.

llvm-svn: 71632
2009-05-13 03:46:30 +00:00
Dan Gohman
cac9b5c5be When forgetting SCEVs for loop PHIs, don't forget SCEVUnknown values.
These values aren't analyzable, so they don't care if more information
about the loop trip count can be had. Also, SCEVUnknown is used for
a PHI while the PHI itself is being analyzed, so it needs to be left
in the Scalars map. This fixes a variety of subtle issues.

llvm-svn: 71533
2009-05-12 01:27:58 +00:00
Dan Gohman
e55d6c4c8a Fix GetMinTrailingZeros for SCEVSignExtend and SCEVZeroExtendExpr to
return the correct value when the cast operand is all zeros. This ought
to be pretty rare, because it would mean that the regular SCEV folding
routines missed a case, though there are cases they might legitimately
miss. Also, it's unlikely anything currently using GetMinTrailingZeros
cares about this case.

llvm-svn: 71532
2009-05-12 01:23:18 +00:00
Eli Friedman
aec1764402 Allow scalar evolution to compute iteration counts for loops with a
pointer-based condition.  This fixes PR3171.

llvm-svn: 71354
2009-05-09 12:32:42 +00:00
Duncan Sands
f7af13b2d4 Rename PaddedSize to AllocSize, in the hope that this
will make it more obvious what it represents, and stop
it being confused with the StoreSize.

llvm-svn: 71349
2009-05-09 07:06:46 +00:00
Dan Gohman
3de703ce43 Don't attempt to handle unsized types in ScalarEvolution's GEP analyzer.
llvm-svn: 71302
2009-05-09 00:14:52 +00:00
Dan Gohman
141989d3c2 Fix bogus overflow checks by replacing them with actual
overflow checks.

llvm-svn: 71284
2009-05-08 23:11:16 +00:00
Dan Gohman
603f022049 Fold trunc casts into add-recurrence expressions, allowing the
add-recurrence to be exposed. Add a new SCEV folding rule to
help simplify expressions in the presence of these extra truncs.

llvm-svn: 71264
2009-05-08 21:03:19 +00:00
Dan Gohman
6eaf7850d8 Fix another bug in r71252. This code supports GetElementPtr
constant exprs as well as instructions.

llvm-svn: 71262
2009-05-08 20:58:38 +00:00
Dan Gohman
f3461c73e8 Add memoization for getSCEVAtScope results for instructions
which are not analyzed with SCEV techniques, which can require
brute-forcing through a large number of instructions. This
fixes a massive compile-time issue on 400.perlbench (in
particular, the loop in MD5Transform).

llvm-svn: 71259
2009-05-08 20:47:27 +00:00
Dan Gohman
1307f44388 Make the SCEV* form of getSCEVAtScope public, to allow ScalarEvolution
clients to use it.

llvm-svn: 71258
2009-05-08 20:38:54 +00:00
Dan Gohman
6d21c4110b Fix an error from r71252.
llvm-svn: 71255
2009-05-08 20:36:47 +00:00
Dan Gohman
afd53ad1a3 Factor out the code for creating SCEVs for GEPs into a
separate function.

llvm-svn: 71252
2009-05-08 20:26:55 +00:00
Dan Gohman
34a6d38d54 Implement several new SCEV folding rules for UDiv SCEVs.
This fixes an old FIXME, and is needed by some upcoming changes.

llvm-svn: 71247
2009-05-08 20:18:49 +00:00
Dan Gohman
93c518ffe9 SCEVComplexityCompare's new code was missing SCEVUDivExpr. Implement
the SCEVUDivExpr case.

llvm-svn: 71173
2009-05-07 19:23:21 +00:00
Dan Gohman
99b6edddf3 Make ScalarEvolution's GroupByComplexity more thorough. In addition
to sorting SCEVs by their kind, sort SCEVs of the same kind according
to their operands. This helps avoid things like (a+b) being a distinct
expression from (b+a).

llvm-svn: 71160
2009-05-07 14:39:04 +00:00
Dan Gohman
dcfbeec0f8 Trim unnecessary headers. Code in Analysis shouldn't use Transforms
headers due to library dependencies.

llvm-svn: 71159
2009-05-07 14:30:26 +00:00
Dan Gohman
b81e43b8c3 Factor out a common base class between SCEVCommutativeExpr and
SCEVAddRecExpr. This eliminates redundant code for visiting
all the operands of an expression.

llvm-svn: 71157
2009-05-07 14:00:19 +00:00
Dan Gohman
dee50585e0 Use stable_sort instead of plain sort to avoid the risk of generating
trivially different code on different hosts (due to differing
std::sort implementations).

llvm-svn: 71124
2009-05-06 22:54:33 +00:00
Dan Gohman
00c4ac3add Re-apply 70645, converting ScalarEvolution to use
CallbackVH, with fixes. allUsesReplacedWith need to
walk the def-use chains and invalidate all users of a
value that is replaced. SCEVs of users need to be
recalcualted even if the new value is equivalent. Also,
make forgetLoopPHIs walk def-use chains, since any
SCEV that depends on a PHI should be recalculated when
more information about that PHI becomes available.

llvm-svn: 70927
2009-05-04 22:30:44 +00:00
Dan Gohman
eecaa636fb Fix an 80-column violation.
llvm-svn: 70925
2009-05-04 22:23:18 +00:00
Dan Gohman
6bfe85b985 Fix doxygen comment syntax.
llvm-svn: 70924
2009-05-04 22:20:30 +00:00
Dan Gohman
6c425d29e7 Constify a bunch of SCEV-using code.
llvm-svn: 70919
2009-05-04 22:02:23 +00:00
Dan Gohman
8e4b9e586b Revert r70645 for now; it's causing a variety of regressions.
llvm-svn: 70661
2009-05-03 05:46:20 +00:00
Dan Gohman
7d98736ca6 Convert ScalarEvolution to use CallbackVH for its internal map. This
makes ScalarEvolution::deleteValueFromRecords, and it's code that
subtly needed to be called before ReplaceAllUsesWith, unnecessary.

It also makes ValueDeletionListener unnecessary.

llvm-svn: 70645
2009-05-02 21:19:20 +00:00
Dan Gohman
9608880839 When ScalarEvolution is told to forget the trip count for a loop, have
it also forget any SCEVs associated with loop-header PHIs in the loop,
as they may be dependent on trip count information.

llvm-svn: 70633
2009-05-02 17:43:35 +00:00
Dan Gohman
0dc2b769b0 When printing a SCEVUnknown with pointer type, don't print an
artificial "ptrtoint", as it tends to clutter up complicated
expressions. The cast operators now print both source and
destination types, which is usually sufficient.

llvm-svn: 70554
2009-05-01 17:02:22 +00:00
Dan Gohman
7eab4d2fa2 Fix an 80-column violation.
llvm-svn: 70550
2009-05-01 16:44:56 +00:00
Dan Gohman
24b592972d When creating cast scevs, canonicalize the destination type. This
avoids duplicate scevs that differ only in type.

llvm-svn: 70549
2009-05-01 16:44:18 +00:00
Torok Edwin
63c28133ae hasSCEV() was declared in ScalarEvolution.h, but never defined. This must have
gone lost during the pImpl conversion.

llvm-svn: 70536
2009-05-01 08:33:47 +00:00
Dan Gohman
6d5f693ede Add some comments, and tidy up some whitespace.
llvm-svn: 70510
2009-04-30 20:48:53 +00:00
Dan Gohman
3c9f4f765c Extend ScalarEvolution's getBackedgeTakenCount to be able to
compute an upper-bound value for the trip count, in addition to
the actual trip count. Use this to allow getZeroExtendExpr and
getSignExtendExpr to fold casts in more cases.

This may eventually morph into a more general value-range
analysis capability; there are certainly plenty of places where
more complete value-range information would allow more folding.

llvm-svn: 70509
2009-04-30 20:47:05 +00:00
Dan Gohman
25d21786d3 Don't try to mix integers and pointers in an icmp instruction
in getSCEVAtScope.

llvm-svn: 70495
2009-04-30 16:40:30 +00:00
Dan Gohman
fac9c52fd8 Fix ScalarEvolution::print to print a value for any Instruction with
a SCEVable type, not just integer types.

llvm-svn: 70463
2009-04-30 01:30:18 +00:00
Dan Gohman
63bab48951 Implement getSCEVAtScope for SCEV cast expressions.
llvm-svn: 70422
2009-04-29 22:29:01 +00:00
Dan Gohman
06aff30f01 Generalize the cast-of-addrec folding to handle folding of SCEVs like
(sext i8 {-128,+,1} to i64) to i64 {-128,+,1}, where the iteration
crosses from negative to positive, but is still safe if the trip
count is within range.

llvm-svn: 70421
2009-04-29 22:28:28 +00:00
Dan Gohman
55befacc69 Include the source type in SCEV cast expression debug output, and
print sext, zext, and trunc, instead of signextend, zeroextend,
and truncate, respectively, for consistency with the main IR.

llvm-svn: 70405
2009-04-29 20:27:52 +00:00
Dale Johannesen
15486ddd95 Fix recent regression in gcc.dg/pr26719.c (6835035).
llvm-svn: 70386
2009-04-29 16:38:47 +00:00
Dan Gohman
4f8ccd5bc8 Update comments to reflect the current code.
llvm-svn: 70357
2009-04-29 01:54:20 +00:00
Dan Gohman
ff30ebd710 Teach getZeroExtendExpr and getSignExtendExpr to use trip-count
information to simplify [sz]ext({a,+,b}) to {zext(a),+,[zs]ext(b)},
as appropriate.

These functions and the trip count code each call into the other, so
this requires careful handling to avoid infinite recursion. During
the initial trip count computation, conservative SCEVs are used,
which are subsequently discarded once the trip count is actually
known.

Among other benefits, this change lets LSR automatically eliminate
some unnecessary zext-inreg and sext-inreg operation where the
operand is an induction variable.

llvm-svn: 70241
2009-04-27 20:16:15 +00:00
Dan Gohman
820b45049b Handle ands with ~0 correctly too. This fixes PR4052.
llvm-svn: 70176
2009-04-27 01:41:10 +00:00
Dan Gohman
9eb5ba6eb7 Handle ands with 0 and shifts by 0 correctly. These aren't
common, but indvars shouldn't crash on them. This fixes PR4054.

llvm-svn: 70051
2009-04-25 17:05:40 +00:00
Nick Lewycky
32cfba44df Simplify trunc(extend(x)) in SCEVs, just for completeness. Also fix some odd
whitespace in the same file.

llvm-svn: 69870
2009-04-23 05:15:08 +00:00
Dan Gohman
d6edb69103 Simplify trivial cast-of-cast SCEVs.
llvm-svn: 69809
2009-04-22 16:20:48 +00:00
Dan Gohman
4cb9d25f4a De-pImpl-ify ScalarEvolution. The pImpl pattern doesn't provide much
practical benefit in the case of ScalarEvolution, and it's otherwise
a nuisance.

llvm-svn: 69749
2009-04-21 23:15:49 +00:00