Nick Lewycky
39b165bb7d
Fix flipped sign. While there, show my math.
...
llvm-svn: 139135
2011-09-06 05:33:18 +00:00
Nick Lewycky
fdc650ea7a
No no no, fix typo properly!
...
llvm-svn: 139134
2011-09-06 05:08:09 +00:00
Nick Lewycky
3823432a57
The logic inside getMulExpr to simplify {a,+,b}*{c,+,d} was wrong, which was
...
visible given a=b=c=d=1, on iteration #1 (the second iteration). Replace it with
correct math. Fixes PR10383!
llvm-svn: 139133
2011-09-06 05:05:14 +00:00
Nick Lewycky
18c0b01a56
Revert r139126 due to selfhost failures reported by buildbots.
...
llvm-svn: 139130
2011-09-06 02:43:13 +00:00
Nick Lewycky
30dcc754df
Teach SCEV to report a max backedge count in one interesting case in
...
HowFarToZero; the case for a canonical loop.
llvm-svn: 139126
2011-09-05 23:25:16 +00:00
Andrew Trick
43d88c3879
Comment and clarifying assert.
...
llvm-svn: 139036
2011-09-02 21:20:46 +00:00
Andrew Trick
5a5a5ebe68
Allow loop unrolling to get known trip counts from ScalarEvolution.
...
SCEV unrolling can unroll loops with arbitrary induction variables. It
is a prerequisite for -disable-iv-rewrite performance. It is also
easily handles loops of arbitrary structure including multiple exits
and is generally more robust.
This is under a temporary option to avoid affecting default
behavior for the next couple of weeks. It is needed so that I can
checkin unit tests for updateUnloop.
llvm-svn: 137384
2011-08-11 23:36:16 +00:00
Andrew Trick
a7fc7983d4
Made SCEV's UDiv expressions more canonical. When dividing a
...
recurrence, the initial values low bits can sometimes be ignored.
To take advantage of this, added FoldIVUser to IndVarSimplify to fold
an IV operand into a udiv/lshr if the operator doesn't affect the
result.
-indvars -disable-iv-rewrite now transforms
i = phi i4
i1 = i0 + 1
idx = i1 >> (2 or more)
i4 = i + 4
into
i = phi i4
idx = i0 >> ...
i4 = i + 4
llvm-svn: 137013
2011-08-06 07:00:37 +00:00
Andrew Trick
86f6a3c645
Use consistent terminology for loop exit/exiting blocks. Name change only.
...
llvm-svn: 136677
2011-08-02 04:23:35 +00:00
Andrew Trick
ae93f1bf46
SCEV: Added a data structure for storing not-taken info per loop
...
exit. Added an interfaces for querying either the loop's exact/max
backedge taken count or a specific loop exit's not-taken count.
llvm-svn: 136100
2011-07-26 17:19:55 +00:00
Jay Foad
ae5894c5cc
Use ArrayRef in ConstantFoldInstOperands and ConstantFoldCall.
...
llvm-svn: 135477
2011-07-19 13:32:40 +00:00
Chris Lattner
e1fe7061ce
land David Blaikie's patch to de-constify Type, with a few tweaks.
...
llvm-svn: 135375
2011-07-18 04:54:35 +00:00
Andrew Trick
b92801a07e
SCEV: missing null check fix for r132360, dragonegg crash.
...
llvm-svn: 132416
2011-06-01 19:14:56 +00:00
Andrew Trick
60ad58febd
scev: Better sign-extend removal. Normalize postincrement recurrences
...
so that their sign extended forms are congruent when no overflow occurs.
llvm-svn: 132360
2011-05-31 21:17:47 +00:00
Dan Gohman
392ab7a6ba
Change a few std::maps to DenseMaps.
...
llvm-svn: 131088
2011-05-09 18:44:09 +00:00
Andrew Trick
270f5fb525
Corrects an old, old typo in a case that doesn't seem to be reached in practice.
...
llvm-svn: 130316
2011-04-27 18:17:36 +00:00
Andrew Trick
cef977b295
Test case and comment for PR9633.
...
llvm-svn: 130294
2011-04-27 05:42:17 +00:00
Andrew Trick
73a354c27e
Fix for PR9633 [indvars] Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
...
Added a type check in ScalarEvolution::computeSCEVAtScope to handle the case in which operands of an
AddRecExpr in the current scope are folded.
llvm-svn: 130271
2011-04-27 01:21:25 +00:00
Dan Gohman
6ff1c50bb5
Fix an iterator invalidation bug.
...
llvm-svn: 130166
2011-04-25 22:48:29 +00:00
Chris Lattner
0304b82f80
Fix a ton of comment typos found by codespell. Patch by
...
Luis Felipe Strano Moraes!
llvm-svn: 129558
2011-04-15 05:18:47 +00:00
Andrew Trick
07887af00c
Added isValidRewrite() to check the result of ScalarEvolutionExpander.
...
SCEV may generate expressions composed of multiple pointers, which can
lead to invalid GEP expansion. Until we can teach SCEV to follow strict
pointer rules, make sure no bad GEPs creep into IR.
Fixes rdar://problem/9038671.
llvm-svn: 127839
2011-03-17 23:51:11 +00:00
Andrew Trick
09d2dcd9ef
Remove getMinusSCEVForExitTest().
...
This function performed acrobatics to prove no-self-wrap, which we now
have for free.
llvm-svn: 127643
2011-03-15 01:16:14 +00:00
Andrew Trick
5c8b815e5f
Propagate SCEV no-wrap flags whenever possible.
...
This needs review.
llvm-svn: 127638
2011-03-15 00:37:00 +00:00
Andrew Trick
da253e79f0
Negating a recurrence preserves no-self-wrap.
...
llvm-svn: 127593
2011-03-14 17:38:54 +00:00
Andrew Trick
dab71254b6
HowFarToZero can compute a trip count as long as the recurrence has no-self-wrap.
...
llvm-svn: 127591
2011-03-14 17:28:02 +00:00
Andrew Trick
5d45b563c5
Added SCEV::NoWrapFlags to manage unsigned, signed, and self wrap
...
properties.
Added the self-wrap flag for SCEV::AddRecExpr.
A slew of temporary FIXMEs indicate the intention of the no-self-wrap flag
without changing behavior in this revision.
llvm-svn: 127590
2011-03-14 16:50:06 +00:00
Andrew Trick
c4703f6ea1
When SCEV can determine the loop test is X < X, set ExactBECount=0.
...
When ExactBECount is a constant, use it for MaxBECount.
When MaxBECount cannot be computed, replace it with ExactBECount.
Fixes PR9424.
llvm-svn: 127342
2011-03-09 17:29:58 +00:00
Andrew Trick
de565b0456
whitespace
...
llvm-svn: 127340
2011-03-09 17:23:39 +00:00
Chris Lattner
2596ac19b9
teach SCEV that the scale and addition of an inbounds gep don't NSW.
...
This fixes a FIXME in scev-aa.ll (allowing a new no-alias result) and
generally makes things more precise.
llvm-svn: 125449
2011-02-13 03:14:49 +00:00
Chris Lattner
fec8b6bd6d
Per discussion with Dan G, inbounds geps *certainly* can have
...
unsigned overflow (e.g. "gep P, -1"), and while they can have
signed wrap in theoretical situations, modelling an AddRec as
not having signed wrap is going enough for any case we can
think of today. In the future if this isn't enough, we can
revisit this. Modeling them as having NUW isn't causing any
known problems either FWIW.
llvm-svn: 125410
2011-02-11 21:43:33 +00:00
Nick Lewycky
fc7a74c9a0
Fix memory corruption. If one of the SCEV creation functions calls another but
...
doesn't return immediately after then the insert position in UniqueSCEVs will
be out of date. No test because this is a memory corruption issue. Fixes PR9051!
llvm-svn: 124282
2011-01-26 08:40:22 +00:00
Dan Gohman
308677c046
Add a comment.
...
llvm-svn: 124126
2011-01-24 17:54:18 +00:00
Nick Lewycky
13a2b8281f
Simplify some code with no functionality change. Make the test a lot more
...
robust against smarter optimizations, using the power of FileCheck.
llvm-svn: 124081
2011-01-23 20:06:05 +00:00
Nick Lewycky
2503c9f9c8
Use value ranges to fold ext(trunc) in SCEV when possible.
...
llvm-svn: 124062
2011-01-23 06:20:19 +00:00
Nick Lewycky
4440e5815b
Have SCEV turn sext(x) into zext(x) when x is s>= 0. This applies many times in
...
"make check" alone.
llvm-svn: 124046
2011-01-22 22:06:21 +00:00
Nick Lewycky
51c13384f5
Similarly, analyze truncate through multiply.
...
llvm-svn: 123842
2011-01-19 18:56:00 +00:00
Nick Lewycky
9867e58096
Add a missed SCEV fold that is required to continue analyzing the IR produced
...
by indvars through the scev expander.
trunc(add x, y) --> add(trunc x, y). Currently SCEV largely folds the other way
which is probably wrong, but preserved to minimize churn. Instcombine doesn't
do this fold either, demonstrating a missed optz'n opportunity on code doing
add+trunc+add.
llvm-svn: 123838
2011-01-19 16:59:46 +00:00
Nick Lewycky
5a538b62ca
Add a missing SCEV simplification sext(zext x) --> zext x.
...
llvm-svn: 123832
2011-01-19 15:56:12 +00:00
Chris Lattner
8c0a70a30c
some comment improvements.
...
llvm-svn: 123243
2011-01-11 17:11:59 +00:00
Eric Christopher
e86e1aecd8
Temporarily revert 123133, it's causing some regressions and I'm trying
...
to get a testcase.
llvm-svn: 123225
2011-01-11 09:02:09 +00:00
Chris Lattner
14bf29d7a0
the GEP faq says that only inbounds geps are guaranteed to not overflow.
...
llvm-svn: 123218
2011-01-11 06:44:41 +00:00
Chris Lattner
0643d32b61
add a fixme: ir isn't expressive enough.
...
llvm-svn: 123139
2011-01-09 23:02:10 +00:00
Chris Lattner
c8a9f4ca2b
Step #4 in improving trip count analysis: HowFarToZero can analyze
...
NUW AddRec's much more aggressively. We now get a trip count
for @test2 in nsw.ll
llvm-svn: 123138
2011-01-09 22:58:47 +00:00
Chris Lattner
09cfec2226
rearrange some code, no functionality change.
...
llvm-svn: 123136
2011-01-09 22:39:48 +00:00
Chris Lattner
4efcd276de
Step #3 to improving trip count analysis: If we fold
...
a + {b,+,stride} into {a+b,+,stride} (because a is LIV),
then the resultant AddRec is NUW/NSW if the client says it
is.
llvm-svn: 123133
2011-01-09 22:31:26 +00:00
Chris Lattner
b6a67a9068
Step #2 to improve trip count analysis for loops like this:
...
void f(int* begin, int* end) { std::fill(begin, end, 0); }
which turns into a != exit expression where one pointer is
strided and (thanks to step #1 ) known to not overflow, and
the other is loop invariant.
The observation here is that, though the IV is strided by
4 in this case, that the IV *has* to become equal to the
end value. It cannot "miss" the end value by stepping over
it, because if it did, the strided IV expression would
eventually wrap around.
Handle this by turning A != B into "A-B != 0" where the A-B
part is known to be NUW.
llvm-svn: 123131
2011-01-09 22:26:35 +00:00
Chris Lattner
57e9b35653
teach SCEV analysis of PHI nodes that PHI recurences formed
...
with GEP instructions are always NUW, because PHIs cannot wrap
the end of the address space.
llvm-svn: 123105
2011-01-09 02:28:48 +00:00
Chris Lattner
fa37cac39c
reduce indentation. Print <nuw> and <nsw> when dumping SCEV AddRec's
...
that have the bit set.
llvm-svn: 123104
2011-01-09 02:16:18 +00:00
Jay Foad
79e18ed269
PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
...
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.
llvm-svn: 121120
2010-12-07 08:25:19 +00:00
Jay Foad
789e8ac4f7
PR5207: Rename overloaded APInt methods set(), clear(), flip() to
...
setAllBits(), setBit(unsigned), etc.
llvm-svn: 120564
2010-12-01 08:53:58 +00:00
Benjamin Kramer
9141603779
Simplify code. No change in functionality.
...
llvm-svn: 119908
2010-11-20 18:43:35 +00:00
Benjamin Kramer
821c39433d
Silence warning about an uninitialized variable.
...
llvm-svn: 119800
2010-11-19 11:37:26 +00:00
Duncan Sands
4562d3b919
Factor code for testing whether replacing one value with another
...
preserves LCSSA form out of ScalarEvolution and into the LoopInfo
class. Use it to check that SimplifyInstruction simplifications
are not breaking LCSSA form. Fixes PR8622.
llvm-svn: 119727
2010-11-18 19:59:41 +00:00
Dan Gohman
3213622610
Introduce memoization for ScalarEvolution dominates and properlyDominates
...
queries, and SCEVExpander getRelevantLoop queries.
llvm-svn: 119595
2010-11-18 00:34:22 +00:00
Dan Gohman
ecff21cc67
Factor out the code for purging a SCEV from all the various memoization maps.
...
Some of these maps may merge in the future, but for now it's convenient to have
a utility function for them.
llvm-svn: 119587
2010-11-17 23:28:48 +00:00
Dan Gohman
8e594dfe39
Merge the implementations of isLoopInvariant and hasComputableLoopEvolution, and
...
memoize the results. This improves compile time in code which highly complex
expressions which get queried many times.
llvm-svn: 119584
2010-11-17 23:21:44 +00:00
Dan Gohman
fb6ea18d0a
Make SCEV::getType() and SCEV::print non-virtual. Move SCEV::hasOperand
...
to ScalarEvolution. Delete SCEV::~SCEV. SCEV is no longer virtual.
llvm-svn: 119578
2010-11-17 22:27:42 +00:00
Dan Gohman
9bbb0fa515
Move SCEV::dominates and properlyDominates to ScalarEvolution.
...
llvm-svn: 119570
2010-11-17 21:41:58 +00:00
Dan Gohman
04df5af12b
Move SCEV::isLoopInvariant and hasComputableLoopEvolution to be member
...
functions of ScalarEvolution, in preparation for memoization and
other optimizations.
llvm-svn: 119562
2010-11-17 21:23:15 +00:00
Duncan Sands
b5fd5f2124
Before replacing a phi node with a different value, it
...
needs to be checked that this won't break LCSSA form.
Change the existing checking method to a more direct one:
rather than seeing if all predecessors belong to the loop,
check that the replacing value is either not in any loop or
is in a loop that contains the phi node.
llvm-svn: 119556
2010-11-17 20:49:12 +00:00
Dan Gohman
4dc0a20aea
Verify SCEVAddRecExpr's invariant in ScalarEvolution::getAddRecExpr
...
instead of in SCEVAddRecExpr's constructor, in preparation for an
upcoming change.
llvm-svn: 119554
2010-11-17 20:48:38 +00:00
Dan Gohman
a585073323
Fix ScalarEvolution's range memoization to avoid using a
...
default ctor with ConstantRange.
llvm-svn: 119550
2010-11-17 20:23:08 +00:00
Duncan Sands
7376a19858
Have ScalarEvolution use SimplifyInstruction rather than hasConstantValue.
...
While there, add a note about an inefficiency I noticed.
llvm-svn: 119458
2010-11-17 04:18:45 +00:00
Dan Gohman
b10ff802a0
Memoize results from ScalarEvolution's getUnsignedRange and getSignedRange.
...
This fixes some extreme compile times on unrolled sha512 code.
llvm-svn: 119455
2010-11-17 02:44:44 +00:00
Dan Gohman
85557399a1
Make ScalarEvolution::forgetLoop forget all contained loops too, because
...
they may have ValuesAtScopes map entries referencing their outer loops.
This fixes a user-after-free reported in PR8471.
llvm-svn: 117698
2010-10-29 20:16:10 +00:00
Owen Anderson
46990c17f7
Get rid of static constructors for pass registration. Instead, every pass exposes an initializeMyPassFunction(), which
...
must be called in the pass's constructor. This function uses static dependency declarations to recursively initialize
the pass's dependencies.
Clients that only create passes through the createFooPass() APIs will require no changes. Clients that want to use the
CommandLine options for passes will need to manually call the appropriate initialization functions in PassInitialization.h
before parsing commandline arguments.
I have tested this with all standard configurations of clang and llvm-gcc on Darwin. It is possible that there are problems
with the static dependencies that will only be visible with non-standard options. If you encounter any crash in pass
registration/creation, please send the testcase to me directly.
llvm-svn: 116820
2010-10-19 17:21:58 +00:00
Owen Anderson
63f757463c
Begin adding static dependence information to passes, which will allow us to
...
perform initialization without static constructors AND without explicit initialization
by the client. For the moment, passes are required to initialize both their
(potential) dependencies and any passes they preserve. I hope to be able to relax
the latter requirement in the future.
llvm-svn: 116334
2010-10-12 19:48:12 +00:00
Owen Anderson
69cbf2e8b7
Now with fewer extraneous semicolons!
...
llvm-svn: 115996
2010-10-07 22:25:06 +00:00
Dan Gohman
ff478951be
Don't add the operand count to SCEV uniquing data; FoldingSetNodeID
...
already knows its own length, so this is redundant.
llvm-svn: 115521
2010-10-04 17:24:08 +00:00
Dan Gohman
fb64948296
Reapply r112432, now that the real problem is addressed.
...
llvm-svn: 112667
2010-08-31 22:53:17 +00:00
Dan Gohman
cadc463790
Reapply r112433, now that the real problem is addressed.
...
llvm-svn: 112666
2010-08-31 22:52:12 +00:00
Dan Gohman
a9b5b6bd36
Revert r110916. This patch is buggy because the code inside the
...
inner loop doesn't update all the variables in the outer loop.
llvm-svn: 112665
2010-08-31 22:50:31 +00:00
Dan Gohman
6822b9d177
Revert r112432. It appears to be exposing a problem in the emacs build.
...
llvm-svn: 112638
2010-08-31 20:58:44 +00:00
Dan Gohman
47865eb626
Speculatively revert r112433.
...
llvm-svn: 112608
2010-08-31 17:56:47 +00:00
Dan Gohman
4e9013673c
Restructure the {A,+,B}<L> * {C,+,D}<L> folding so that it folds
...
all applicable addrecs before recursing on getMulExpr, instead of
recursing on getMulExpr for each one.
llvm-svn: 112433
2010-08-29 15:16:58 +00:00
Dan Gohman
88b40ae04a
Batch up subtracts along with adds, when analyzing long chains of
...
operations.
llvm-svn: 112432
2010-08-29 15:10:06 +00:00
Dan Gohman
988c90a5e1
Micro-optimize GroupByComplexity.
...
llvm-svn: 112431
2010-08-29 15:07:13 +00:00
Dan Gohman
690916c085
Hold AddRec->getLoop() in a variable, to make the Mul code more consistent
...
with the Add code.
llvm-svn: 112430
2010-08-29 14:55:19 +00:00
Dan Gohman
5a3ad9c218
Rename a variable, for consistency.
...
llvm-svn: 112429
2010-08-29 14:53:34 +00:00
Dan Gohman
d581ece72a
Use iterators instead of indices.
...
llvm-svn: 112428
2010-08-29 14:52:02 +00:00
Dan Gohman
aa972a1ee3
Fix an index calculation thinko.
...
llvm-svn: 112337
2010-08-28 00:39:27 +00:00
Dan Gohman
ee0a450648
When merging adjacent operands, scan ahead and merge all equal
...
adjacent operands at once, instead of just two at a time.
llvm-svn: 112299
2010-08-27 21:39:59 +00:00
Dan Gohman
f950201d01
Make the {A,+,B}<L> + {C,+,D}<L> --> Other + {A+C,+,B+D}<L>
...
transformation collect all the addrecs with the same loop
add combine them at once rather than starting everything over
at the first chance.
llvm-svn: 112290
2010-08-27 20:45:56 +00:00
Dan Gohman
636c57c5de
Switch ScalarEvolution's main Value*->SCEV* map from std::map
...
to DenseMap.
llvm-svn: 112281
2010-08-27 18:55:03 +00:00
Dan Gohman
e1fcf40b52
Optimize SCEVComplexityCompare. Use a 3-way return instead of a 2-way
...
return to avoid needing two calls to test for equivalence, and sort
addrecs by their degree before examining their operands.
llvm-svn: 112267
2010-08-27 15:26:01 +00:00
Dan Gohman
013400a0f9
To create a copy of a SmallVector with an element removed from the
...
middle, copy the elements in two groups, rather than copying all the
elements and then doing an erase on the middle of the result. These
are SmallVectors, so we shouldn't expect to hit dynamic allocation
in the common case.
llvm-svn: 111151
2010-08-16 16:57:24 +00:00
Dan Gohman
7312563612
Tidy whitespace.
...
llvm-svn: 111147
2010-08-16 16:34:09 +00:00
Dan Gohman
8281459eb0
Add a comment.
...
llvm-svn: 111145
2010-08-16 16:31:39 +00:00
Dan Gohman
71323d2cfe
Use const_iterator in a few places.
...
llvm-svn: 111144
2010-08-16 16:30:01 +00:00
Dan Gohman
b0604c0b83
Use iterators instead of indices in a few more places.
...
llvm-svn: 111143
2010-08-16 16:27:53 +00:00
Dan Gohman
64c713c605
Micro-optimize SCEVConstant comparison.
...
llvm-svn: 111142
2010-08-16 16:25:35 +00:00
Dan Gohman
6d808db278
Move SCEVNAryExpr's virtual member functions out of line, and convert
...
them to iterators.
llvm-svn: 111140
2010-08-16 16:21:27 +00:00
Dan Gohman
d55de2457e
Use iterators instead of indices in simple cases.
...
llvm-svn: 111138
2010-08-16 16:16:11 +00:00
Dan Gohman
daec40b96d
Avoid gratuitous inefficiency in ifndef NDEBUG code.
...
llvm-svn: 111137
2010-08-16 16:13:54 +00:00
Dan Gohman
345dc8add7
Make one getAddExpr call when analyzing a+b+c+d+e+... instead of one
...
for each add instruction. Ditto for Mul.
llvm-svn: 111136
2010-08-16 16:03:49 +00:00
Dan Gohman
fec602e7c5
Delete an unused function.
...
llvm-svn: 111135
2010-08-16 15:57:14 +00:00
Dan Gohman
076597a026
Various optimizations. Don't compare two loops' depths
...
when they are the same loop. Don't compare two instructions'
loop depths when they are in the same block.
llvm-svn: 111045
2010-08-13 21:24:58 +00:00
Dan Gohman
ecb279a1c2
When testing whether one loop contains another, test this directly
...
rather than testing whether the loop contains the other's header.
llvm-svn: 111039
2010-08-13 20:23:25 +00:00
Dan Gohman
02de74d4dc
Add a const.
...
llvm-svn: 111038
2010-08-13 20:17:27 +00:00
Dan Gohman
3650d2058f
When creating a symmetric SCEV with a constant operand, put
...
the constant operand on the left, as that's where ScalarEvolution
will end up canonicalizing to.
llvm-svn: 111037
2010-08-13 20:17:14 +00:00
Dan Gohman
de171ff360
An add recurrence is loop-invariant in any loop inside of its
...
associated loop. This avoids potentially expensive traversals
of the add recurrence's operands.
llvm-svn: 111034
2010-08-13 20:11:39 +00:00
Dan Gohman
8103471a35
Optimize ScalarEvolution::getAddExpr's operand factoring code by
...
having it finish processing all of the muliply operands before
starting the whole getAddExpr process over again, instead of
immediately after the first simplification.
llvm-svn: 110916
2010-08-12 15:00:23 +00:00
Dan Gohman
d7b79a35df
Hoist some loop-invariant code out of a hot loop.
...
llvm-svn: 110915
2010-08-12 14:52:55 +00:00
Dan Gohman
cc5fb07653
Optimize ScalarEvolution::getAddExpr's duplicate operand detection
...
by having it finish processing the whole operand list before
starting the whole getAddExpr process over again, instead of
immediately after the first duplicate is found.
llvm-svn: 110914
2010-08-12 14:46:54 +00:00
Dan Gohman
603e66618f
When analyzing loop exit conditions combined with and and or, don't
...
make any assumptions about when the two conditions will agree on when
to permit the loop to exit. This fixes PR7845.
llvm-svn: 110758
2010-08-11 00:12:36 +00:00
Dan Gohman
7e49302e9a
Rename and reorder the arguments to isImpliedCond, for consistency and clarity.
...
llvm-svn: 110750
2010-08-10 23:46:30 +00:00
Owen Anderson
f2fea95f2f
Reapply r110396, with fixes to appease the Linux buildbot gods.
...
llvm-svn: 110460
2010-08-06 18:33:48 +00:00
Owen Anderson
aadd8a89ca
Revert r110396 to fix buildbots.
...
llvm-svn: 110410
2010-08-06 00:23:35 +00:00
Owen Anderson
b9762c07cb
Don't use PassInfo* as a type identifier for passes. Instead, use the address of the static
...
ID member as the sole unique type identifier. Clean up APIs related to this change.
llvm-svn: 110396
2010-08-05 23:42:04 +00:00
Dan Gohman
bafce59252
Fix a minor bug which resulted in intermediate calculations
...
using wider types than are necessary.
llvm-svn: 110241
2010-08-04 19:52:50 +00:00
Dan Gohman
68ac0492a4
Make SCEVUnknown a CallbackVH, so that it can be notified directly
...
of Value deletions and RAUWs, instead of relying on ScalarEvolution's
Scalars map being notified, as that's complicated at best, and
insufficient in general.
This means SCEVUnknown needs a non-trivial destructor, so introduce
a mechanism to allow ScalarEvolution to locate all the SCEVUnknowns.
llvm-svn: 110086
2010-08-02 23:49:30 +00:00
Oscar Fuentes
4742c01c2a
Prefix next' iterator operation with
llvm::'.
...
Fixes potential ambiguity problems on VS 2010.
Patch by nobled!
llvm-svn: 110029
2010-08-02 06:00:15 +00:00
Eric Christopher
6a1da7b4a5
Speculatively revert r109705 since it seems to be causing some build bot
...
angst.
llvm-svn: 109718
2010-07-29 01:25:38 +00:00
Dan Gohman
ea1486b53c
Factor out some of the code for updating old SCEVUnknown values, and
...
extend it to handle the case where multiple RAUWs affect a single
SCEVUnknown.
Add a ScalarEvolution unittest to test for this situation.
llvm-svn: 109705
2010-07-29 00:17:55 +00:00
Dan Gohman
2bea1e1572
Make SCEVCallbackVH::allUsesReplacedWith update the old SCEVUnknown
...
object, as it may still be referenced by SCEVs not cleaned up by the
use list traversal.
Also, in ScalarEvolution::forgetValue, only check for a SCEVUnknown
object for the original value, not for any value in the use list,
because other SCEVUnknown values aren't necessary obsolete at that
point.
llvm-svn: 109570
2010-07-28 01:09:07 +00:00
Dan Gohman
9a6ea54d94
Make SCEVCallbackVH::allUsesReplacedWith unconditionally delete
...
the old value.
llvm-svn: 109567
2010-07-28 00:28:25 +00:00
Dan Gohman
188a4d7d53
Micro-optimize SCEVComplexityCompare.
...
llvm-svn: 109267
2010-07-23 21:20:52 +00:00
Dan Gohman
2de2b0713e
Add a const qualifier.
...
llvm-svn: 109266
2010-07-23 21:18:55 +00:00
Gabor Greif
96a9f8c7c6
mass elimination of reliance on automatic iterator dereferencing
...
llvm-svn: 109103
2010-07-22 13:36:47 +00:00
Owen Anderson
f8addbb0a1
Fix batch of converting RegisterPass<> to INTIALIZE_PASS().
...
llvm-svn: 109045
2010-07-21 22:09:45 +00:00
Dan Gohman
61bb92a5ff
Add a fast path for x - x.
...
llvm-svn: 108855
2010-07-20 16:53:00 +00:00
Dan Gohman
04768aa9a5
Teach ScalarEvolution how to fold trunc(undef) and anyext(undef) to undef.
...
This helps LSR behave more consistently on bugpoint-reduced testcases.
llvm-svn: 108451
2010-07-15 20:02:11 +00:00
Dan Gohman
547c92af20
In ScalarEvolution::forgetValue, eliminate any SCEVUnknown
...
entries associated with the value being erased in the
folding set map. These entries used to be harmless, because
a SCEVUnknown doesn't store any information about its Value*,
so having a new Value allocated at the old Value's address
wasn't a problem. But now that ScalarEvolution is storing more
information about values, this is no longer safe.
llvm-svn: 107316
2010-06-30 20:21:12 +00:00
Dan Gohman
683a9e2498
Revert the part of r107257 which introduced new logic for using
...
nsw and nuw flags from IR Instructions. On further consideration,
this isn't valid.
llvm-svn: 107298
2010-06-30 17:27:11 +00:00
Dan Gohman
b7fc09a156
Improve ScalarEvolution's nsw and nuw preservation.
...
llvm-svn: 107257
2010-06-30 07:16:37 +00:00
Dan Gohman
7446416058
When computing a new ConservativeResult, intersect it with
...
the old one instead of replacing it, to be more precise.
llvm-svn: 107256
2010-06-30 06:58:35 +00:00
Dan Gohman
32534063c7
Fix ScalarEvolution's tripcount computation for chains of loops
...
where each loop's induction variable's start value is the exit
value of a preceding loop.
llvm-svn: 107224
2010-06-29 23:43:06 +00:00
Dan Gohman
f5dfb360be
Just as its not safe to blindly transfer the nsw bit from an add
...
instruction to an add scev, it's not safe to blindly transfer the
inbounds flag from a gep instruction to an nsw on the scev for the
gep.
llvm-svn: 107117
2010-06-29 01:41:41 +00:00
Dan Gohman
01de3704f9
Eliminate a redundant FoldingSet lookup.
...
llvm-svn: 106872
2010-06-25 18:47:08 +00:00
Dan Gohman
bfbfa95b51
Don't try to preserve pointer types in SCEVConstants; the old code
...
was over-complicated.
llvm-svn: 106760
2010-06-24 16:47:03 +00:00
Dan Gohman
35a5a7285a
Make the trunc code consistent with the zext and sext code in its
...
handling of pointer types.
llvm-svn: 106757
2010-06-24 16:33:38 +00:00
Dan Gohman
f44783ab4e
Replace ScalarEvolution's private copy of getLoopPredecessor
...
with LoopInfo's public copy.
llvm-svn: 106603
2010-06-22 23:43:28 +00:00
Dan Gohman
a3bc6b13f7
Allow "exhaustive" trip count evaluation on phi nodes with all
...
constant operands.
llvm-svn: 106537
2010-06-22 13:15:46 +00:00
Dan Gohman
6a3c46ad49
Use A.append(...) instead of A.insert(A.end(), ...) when A is a
...
SmallVector, and other SmallVector simplifications.
llvm-svn: 106452
2010-06-21 19:47:52 +00:00
Dan Gohman
cec5b682b6
Fix ScalarEvolution's "exhaustive" trip count evaluation code to avoid
...
assuming that loops are in canonical form, as ScalarEvolution doesn't
depend on LoopSimplify itself. Also, with indirectbr not all loops can
be simplified. This fixes PR7416.
llvm-svn: 106389
2010-06-19 14:17:24 +00:00
Dan Gohman
b5ec637e57
Revert r106304 (105548 and friends), which are the SCEVComplexityCompare
...
optimizations. There is still some nondeterminism remaining.
llvm-svn: 106306
2010-06-18 19:54:20 +00:00
Dan Gohman
527b570925
Reapply 105540, 105542, and 105548, and revert r105732.
...
llvm-svn: 106304
2010-06-18 19:26:04 +00:00
Dan Gohman
75f6f94c48
Reapply 105546.
...
llvm-svn: 106302
2010-06-18 19:12:32 +00:00
Dan Gohman
ab895769a7
Reapply 105544.
...
llvm-svn: 106301
2010-06-18 19:09:27 +00:00
Dan Gohman
e20e668c7e
Remove getIntegerSCEV; it's redundant with getConstant, and getConstant
...
is more consistent with the ConstantInt API.
llvm-svn: 106281
2010-06-18 14:33:50 +00:00
Dan Gohman
1d9d93381a
Simplify this code.
...
llvm-svn: 106254
2010-06-17 23:34:09 +00:00
Evan Cheng
28c151ae52
Revert 105540, 105542, 105544, 105546, and 105548 to unbreak bootstrapping.
...
llvm-svn: 105740
2010-06-09 18:59:43 +00:00
Dan Gohman
490f4d7020
The FoldingSet hash data includes pointer values, so it isn't
...
determinstic. Instead, give SCEV objects an arbitrary sequence
number.
llvm-svn: 105548
2010-06-07 19:36:14 +00:00
Dan Gohman
ee75f6f4dd
Optimize this code somewhat by taking advantage of the fact
...
that the operands are sorted.
llvm-svn: 105546
2010-06-07 19:20:57 +00:00
Dan Gohman
e4676a62de
Micro-optimize this, to speed up this hotspot in debug builds a little.
...
llvm-svn: 105544
2010-06-07 19:16:37 +00:00
Dan Gohman
044a968609
Micro-optimize this.
...
llvm-svn: 105542
2010-06-07 19:12:54 +00:00
Dan Gohman
65954b2eb4
Optimize ScalarEvolution's SCEVComplexityCompare predicate: don't go
...
scrounging through SCEVUnknown contents and SCEVNAryExpr operands;
instead just do a simple deterministic comparison of the precomputed
hash data.
Also, since this is more precise, it eliminates the need for the slow
N^2 duplicate detection code.
llvm-svn: 105540
2010-06-07 19:06:13 +00:00
Dan Gohman
5ba21692e6
ConstantFoldConstantExpression can theoretically return null.
...
llvm-svn: 104948
2010-05-28 16:12:08 +00:00
Dan Gohman
5c61a913b2
Use the SCEVAddRecExpr::getPostIncExpr utility function instead
...
of doing the same thing manually.
llvm-svn: 102997
2010-05-04 01:12:27 +00:00
Dan Gohman
4e1dbacdf8
Fix a copy+pasto.
...
llvm-svn: 102996
2010-05-04 01:11:15 +00:00