1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00
Commit Graph

2612 Commits

Author SHA1 Message Date
Dan Gohman
5e41986999 Make TargetData optional in MemoryDependenceAnalysis.
llvm-svn: 77727
2009-07-31 20:53:12 +00:00
Dan Gohman
9c6c4d57be Remove an unnecessary header.
llvm-svn: 77725
2009-07-31 20:47:45 +00:00
Owen Anderson
1dc40e205b Move a few more APIs back to 2.5 forms. The only remaining ones left to change back are
metadata related, which I'm waiting on to avoid conflicting with Devang.

llvm-svn: 77721
2009-07-31 20:28:14 +00:00
Dan Gohman
173cfdc02f Fix some problems with ASTCallbackVH in its use as a DenseMap key.
llvm-svn: 77696
2009-07-31 18:21:48 +00:00
Devang Patel
34cec19943 Process DbgDeclareInst.
llvm-svn: 77694
2009-07-31 18:18:52 +00:00
Owen Anderson
d0e6352c97 Move getTrue() and getFalse() to 2.5-like APIs.
llvm-svn: 77685
2009-07-31 17:39:07 +00:00
Owen Anderson
93ccaf5c60 Move more code back to 2.5 APIs.
llvm-svn: 77635
2009-07-30 23:03:37 +00:00
Dan Gohman
30dfed41b8 Use CallbackVH in AliasSetTracker to avoid getting stuck with
dangling Value*s.

llvm-svn: 77623
2009-07-30 20:21:41 +00:00
Devang Patel
ab56b759af s/DebugInfoEnumerator/DebugInfoFinder/g
llvm-svn: 77615
2009-07-30 18:25:15 +00:00
Devang Patel
751490b934 walk DbgRegionStartInst and DbgRegionEndInst
llvm-svn: 77604
2009-07-30 17:30:23 +00:00
Andreas Bolka
56d7bc03dd Equal SCEVs of a subscript give rise to dependence.
llvm-svn: 77570
2009-07-30 02:26:01 +00:00
Douglas Gregor
8c9b60cabc Eliminate a few unused-variable warnings
llvm-svn: 77519
2009-07-29 22:41:10 +00:00
Owen Anderson
881d928f9b Move types back to the 2.5 API.
llvm-svn: 77516
2009-07-29 22:17:13 +00:00
Owen Anderson
0ce2151b36 Move ConstantExpr to 2.5 API.
llvm-svn: 77494
2009-07-29 18:55:55 +00:00
Andreas Bolka
eb2d2f79b8 Skeleton for pairwise subscript testing.
llvm-svn: 77437
2009-07-29 05:35:53 +00:00
Owen Anderson
390e9778d4 Return ConstantVector to 2.5 API.
llvm-svn: 77366
2009-07-28 21:19:26 +00:00
Devang Patel
5aba07663b Add DebugInfoEnumerator to collect debug info.
llvm-svn: 77360
2009-07-28 19:55:13 +00:00
Andreas Bolka
415bdb47a8 Simplify LDA-internal interface.
llvm-svn: 77359
2009-07-28 19:50:13 +00:00
Andreas Bolka
a9b0af9da7 Add LDA statistics.
llvm-svn: 77358
2009-07-28 19:49:49 +00:00
Andreas Bolka
aa84e1d9d3 Minor factoring, naming and formatting cleanups.
llvm-svn: 77357
2009-07-28 19:49:25 +00:00
Owen Anderson
aa8c94b051 Change ConstantArray to 2.5 API.
llvm-svn: 77347
2009-07-28 18:32:17 +00:00
Dan Gohman
0d0dd7b732 Teach instcombine to respect and preserve inbounds. Add inbounds
to a few tests where it is required for the expected transformation.

llvm-svn: 77290
2009-07-28 01:40:03 +00:00
Owen Anderson
d729f993b8 Move ConstantStruct back to 2.5 API.
llvm-svn: 77266
2009-07-27 22:29:26 +00:00
Owen Anderson
256c2c250e Move ConstantFP construction back to the 2.5-ish API.
llvm-svn: 77247
2009-07-27 20:59:43 +00:00
Dan Gohman
e999569f50 Fix wording in comments.
llvm-svn: 77193
2009-07-27 16:09:48 +00:00
Daniel Dunbar
4a36d5dcfd Remove Value::getName{Start,End}, the last of the old Name APIs.
llvm-svn: 77152
2009-07-26 09:48:23 +00:00
Daniel Dunbar
64abfd0337 Remove Value::getNameLen
llvm-svn: 77148
2009-07-26 08:34:35 +00:00
Dan Gohman
0781059503 SCEV objects are no longer reference-counted.
llvm-svn: 77080
2009-07-25 16:18:07 +00:00
Dan Gohman
c126330ef1 When attempting to sign-extend an addrec by interpreting
the step value as unsigned, the start value and the addrec
itself still need to be treated as signed.

llvm-svn: 77078
2009-07-25 16:03:30 +00:00
Andreas Bolka
72c14efff0 Convert DOUT to DEBUG.
llvm-svn: 77065
2009-07-25 12:19:58 +00:00
Dan Gohman
13aabe2ba4 Teach ScalarEvolution to make use of no-overflow flags when
analyzing add recurrences.

llvm-svn: 77034
2009-07-25 01:22:26 +00:00
Dan Gohman
a823846bd1 Instead of eagerly creating new SCEVs to replace all SCEVs that are
affected after a PHI node has been analyzed, just remove affected
SCEVs from the Scalars map, so that they'll be (lazily) recreated as
needed. This avoids creating SCEV objects that aren't actually needed.

Also, rewrite the associated def-use walking code to be non-recursive
and to continue traversing past Instructions that don't have an
entry in the Scalars map.

llvm-svn: 77032
2009-07-25 01:13:03 +00:00
Dan Gohman
acc5d6eaae Make AliasAnalysis and related classes use
getAnalysisIfAvailable<TargetData>().

llvm-svn: 77028
2009-07-25 00:48:42 +00:00
Daniel Dunbar
8496064116 More migration to raw_ostream, the water has dried up around the iostream hole.
- Some clients which used DOUT have moved to DEBUG. We are deprecating the
   "magic" DOUT behavior which avoided calling printing functions when the
   statement was disabled. In addition to being unnecessary magic, it had the
   downside of leaving code in -Asserts builds, and of hiding potentially
   unnecessary computations.

llvm-svn: 77019
2009-07-25 00:23:56 +00:00
Andreas Bolka
4e68450b70 Forward-declare raw_ostream.
llvm-svn: 77014
2009-07-24 23:19:28 +00:00
Owen Anderson
cc33e89571 Revert the ConstantInt constructors back to their 2.5 forms where possible, thanks to contexts-on-types. More to come.
llvm-svn: 77011
2009-07-24 23:12:02 +00:00
Daniel Dunbar
1df20e31e5 Move to raw_ostream.
llvm-svn: 76963
2009-07-24 09:53:24 +00:00
Daniel Dunbar
e3fea713f1 Switch to getNameStr().
llvm-svn: 76962
2009-07-24 08:24:36 +00:00
Dan Gohman
4c5b26a78e Fix whitespace.
llvm-svn: 76929
2009-07-24 01:03:59 +00:00
Daniel Dunbar
b5adc13728 Convert StringMap to using StringRef for its APIs.
- Yay for '-'s and simplifications!

 - I kept StringMap::GetOrCreateValue for compatibility purposes, this can
   eventually go away. Likewise the StringMapEntry Create functions still follow
   the old style.

 - NIFC.

llvm-svn: 76888
2009-07-23 18:17:34 +00:00
Andreas Bolka
f0462da445 Cache dependence computation using FoldingSet.
This introduces an LDA-internal DependencePair class. The intention is,
that this is a place where dependence testers can store various results
such as SCEVs describing conflicting iterations, breaking conditions,
distance/direction vectors, etc.

llvm-svn: 76877
2009-07-23 14:32:46 +00:00
Andreas Bolka
b33d956e21 Minor cosmetics: indentation, formatting, naming.
llvm-svn: 76839
2009-07-23 01:57:06 +00:00
Devang Patel
7b31d8224d Fix thinko.
llvm-svn: 76769
2009-07-22 18:56:16 +00:00
Devang Patel
a047636be2 Add replaceAllUsesWith() to FE replace debug info constructs while building complex types.
llvm-svn: 76765
2009-07-22 18:23:44 +00:00
Owen Anderson
cc287b28c9 Get rid of the Pass+Context magic.
llvm-svn: 76702
2009-07-22 00:24:57 +00:00
Dan Gohman
190d29cb5c Replace the original ad-hoc code for determining whether (v pred w) implies
(x pred y) with more thorough code that does more complete canonicalization
before resorting to range checks. This helps it find more cases where
the canonicalized expressions match.

llvm-svn: 76671
2009-07-21 23:03:19 +00:00
Owen Anderson
7f61f8dc30 Rename getConstantInt{True|False} to get{True|False} at Chris' behest.
llvm-svn: 76598
2009-07-21 18:03:38 +00:00
Dan Gohman
00fa00fec8 Make the range calculations for addrecs to be more conservative,
as they aren't currently prepared to handle complicated overflow
cases.

llvm-svn: 76524
2009-07-21 00:42:47 +00:00
Dan Gohman
4100aea6ad Whitespace cleanups.
llvm-svn: 76523
2009-07-21 00:38:55 +00:00
Dan Gohman
a37a433693 Minor code simplification.
llvm-svn: 76521
2009-07-21 00:37:45 +00:00
Dan Gohman
47100f32c0 Add a comment to clarify why there isn't any code in this spot.
llvm-svn: 76505
2009-07-20 23:54:43 +00:00
Dan Gohman
857ccb8149 Remove the code that tried to evaluate whether (A pred B) is known
by determining if (B pred (B-A)) is known, as it doesn't handle
overflow correctly.

llvm-svn: 76504
2009-07-20 23:53:35 +00:00
Dan Gohman
b92b14f20b Minor code simplification.
llvm-svn: 76496
2009-07-20 22:41:51 +00:00
Dan Gohman
74a435e9f1 The upper argument of ConstantRange is exclusive, not inclusive.
llvm-svn: 76492
2009-07-20 22:34:18 +00:00
Dan Gohman
721e006395 Update this comment.
llvm-svn: 76438
2009-07-20 17:44:17 +00:00
Dan Gohman
00b05492f1 Revert the addition of hasNoPointerOverflow to GEPOperator.
Getelementptrs that are defined to wrap are virtually useless to
optimization, and getelementptrs that are undefined on any kind
of overflow are too restrictive -- it's difficult to ensure that
all intermediate addresses are within bounds. I'm going to take
a different approach.

Remove a few optimizations that depended on this flag.

llvm-svn: 76437
2009-07-20 17:43:30 +00:00
Nick Lewycky
ec10fcbd04 Replace intersectWith with maximalIntersectWith. The latter guarantees that
all values belonging to the intersection will belong to the resulting range.
The former was inconsistent about that point (either way is fine, just pick
one.) This is part of PR4545.

llvm-svn: 76289
2009-07-18 06:34:42 +00:00
Dan Gohman
93cbd452ed Make BasicAliasAnalysis and Value::getUnderlyingObject use
GEPOperator's hasNoPointer0verflow(), and make a few places in instcombine
that create GEPs that may overflow clear the NoOverflow value. Among
other things, this partially addresses PR2831.

llvm-svn: 76252
2009-07-17 22:25:10 +00:00
Dan Gohman
25a722cc45 Add a new Operator class, for handling Instructions and ConstantExprs
in a convenient manner, factoring out some common code from
InstructionCombining and ValueTracking. Move the contents of
BinaryOperators.h into Operator.h and use Operator to generalize them
to support ConstantExprs as well as Instructions.

llvm-svn: 76232
2009-07-17 20:47:02 +00:00
Eli Friedman
b56b3ca224 Replace isTrapping with a new, similar method called
isSafeToSpeculativelyExecute. The new method is a bit closer to what 
the callers actually care about in that it rejects more things callers 
don't want.  It also adds more precise handling for integer 
division, and unifies code for analyzing the legality of a speculative 
load.

llvm-svn: 76150
2009-07-17 04:28:42 +00:00
Owen Anderson
21d2d69727 Move the ConstantInt uniquing table into LLVMContextImpl. This exposed a number of issues in
our current context-passing stuff, which is also fixed here

llvm-svn: 76089
2009-07-16 18:04:31 +00:00
Dan Gohman
50e65d8c93 Fill in some holes in ScalarEvolution's loop iteration condition
analysis. This allows indvars to emit a simpler loop trip count
expression.

llvm-svn: 76085
2009-07-16 17:34:36 +00:00
Dan Gohman
69d03cf2ee Add an isLoopSimplifyForm() predicate, following the example of
isLCSSAForm(), to test whether a loop is in the form guaranteed
by the LoopSimplify pass.

llvm-svn: 76077
2009-07-16 16:16:23 +00:00
Ted Kremenek
1ebb7e72fa Lexically order files in CMakeLists.txt files.
llvm-svn: 75831
2009-07-15 21:08:16 +00:00
Dan Gohman
81885d5b80 Make makeLoopInvariant report whether it made any changes or not,
and use this to simplify more code.

llvm-svn: 75722
2009-07-15 01:25:43 +00:00
Owen Anderson
8c85061ee6 Move EVER MORE stuff over to LLVMContext.
llvm-svn: 75703
2009-07-14 23:09:55 +00:00
Dan Gohman
5329511fae Fix the expansion of umax and smax in the case where one or more of
the operands have pointer type, so that the resulting type matches
the original SCEV type, and so that unnecessary ptrtoints are
avoided in common cases.

llvm-svn: 75680
2009-07-14 20:57:04 +00:00
Ted Kremenek
98ad0f7632 Update CMake file.
llvm-svn: 75666
2009-07-14 19:46:07 +00:00
Torok Edwin
bbccd95874 Introduce a pointertracking pass.
For now this only computes the allocated size of the memory pointed to by a
pointer, and offset a pointer from allocated pointer.
The actual checkLimits part will come later, after another round of review.

llvm-svn: 75657
2009-07-14 18:44:28 +00:00
Torok Edwin
f955a6ef49 llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.
This adds location info for all llvm_unreachable calls (which is a macro now) in
!NDEBUG builds.
In NDEBUG builds location info and the message is off (it only prints
"UREACHABLE executed").

llvm-svn: 75640
2009-07-14 16:55:14 +00:00
Dan Gohman
5069f6b40f Make SCEVCallbackVH::allUsesReplacedWith more thorough in removing
users from the Scalars map.

llvm-svn: 75634
2009-07-14 14:34:04 +00:00
Dan Gohman
e69947ca6e Add a comment about why ScalarEvolution doesn't recognize non-loop PHIs
even when they're obvious.

llvm-svn: 75632
2009-07-14 14:06:25 +00:00
Daniel Dunbar
21b7f85dc3 ProfileInfo interface tweaks.
- Add getExecutionCount(const Function).

 - Add helper Edge type.

 - constify.

 - No functionality change.

llvm-svn: 75623
2009-07-14 06:58:59 +00:00
Dan Gohman
80062e52e0 Introduce a new LoopInfo utility function makeLoopInvariant, which
works similar to isLoopInvariant, except that it will do trivial
hoisting to try to make the value loop invariant if it isn't already.
This makes it easier for transformation passes to clear trivial
instructions out of the way (the regular LICM pass doesn't run
until relatively late). This is code factored out of LoopSimplify
and other places.

llvm-svn: 75578
2009-07-14 01:06:29 +00:00
Dan Gohman
46fa731fe5 Add a newline, now that Value's operator<< doesn't print one.
llvm-svn: 75568
2009-07-14 00:32:49 +00:00
Owen Anderson
1404d6e7d1 Move more functionality over to LLVMContext.
llvm-svn: 75559
2009-07-13 23:50:59 +00:00
Dan Gohman
fd3cc860ec Print a newline after printing a Value, now that Value's operator<<
doesn't print a newline.

llvm-svn: 75543
2009-07-13 23:03:05 +00:00
Dan Gohman
5c3d16883e Fix a few assertion strings.
llvm-svn: 75530
2009-07-13 22:20:53 +00:00
Dan Gohman
8e93bc202e Forward-declare Loop and LoopInfo instead of #including LoopInfo.h.
llvm-svn: 75529
2009-07-13 22:19:41 +00:00
Dan Gohman
b8ec6716fd Whitespace cleanups.
llvm-svn: 75525
2009-07-13 22:05:32 +00:00
Dan Gohman
370f5f3116 Fix an 80-column violation.
llvm-svn: 75524
2009-07-13 22:04:06 +00:00
Dan Gohman
9a7df22e10 Move isLCSSAForm, isLoopInvariant, getCanonicalInductionVariable,
and related functions out of LoopBase and into Loop, since they
are specific to BasicBlock-based loops. This also allows the code
to be moved out-of-line.

llvm-svn: 75523
2009-07-13 22:02:44 +00:00
Dan Gohman
f6caa6f1e3 Make Loop and MachineLoop be subclasses of LoopBase, rather than typedefs,
using the Curiously Recurring Template Pattern with LoopBase.

This will help further refactoring, and future functionality for
Loop. Also, Headers can now foward-declare Loop, instead of pulling
in LoopInfo.h or doing tricks.

llvm-svn: 75519
2009-07-13 21:51:15 +00:00
Dan Gohman
a9953c0a28 Reapply 75252, with a fix to avoid the infinite recursion case. The
check for avoiding re-analyzing a widening cast needed to happen
earlier, as getSCEV itself may result in a isLoopGuardedByCond query.

llvm-svn: 75511
2009-07-13 21:35:55 +00:00
Owen Anderson
1e5155161a Move more functionality over to LLVMContext.
llvm-svn: 75497
2009-07-13 20:58:05 +00:00
Dan Gohman
1a780ad8db Move the memoization check for SCEVSignExtendExpr and
SCEVZeroExtendExpr ahead of the most expensive analysis. This
speeds up analysis and helps avoid pathologically bad behavior
on the testcase in PR4534.

llvm-svn: 75496
2009-07-13 20:55:53 +00:00
Dan Gohman
bf3719359b Convert SCEV from FoldingSetNode to FastFoldingSetNode. This eliminates
a bunch of redundent code in Profile methods, and prepares for upcoming
changes to do improved memoization.

llvm-svn: 75494
2009-07-13 20:50:19 +00:00
Chris Lattner
11cf698cf7 factor the 'optimized sort' code out into a static helper function
and use it from one more place.  Patch by Jakub Staszak!

llvm-svn: 75478
2009-07-13 17:20:05 +00:00
Chris Lattner
b4bd955891 Move the re-sort of invalidated NonLocalPointerDeps cache earlier
so that all code paths get it.  PR4256 was about a case where the
phi translation loop would find all preds in the Visited cache, so
it could get by without re-sorting the NonLocalPointerDeps cache.
Fix this by resorting it earlier, there is no reason not to do this.

This patch inspired by Jakub Staszak's patch.

llvm-svn: 75476
2009-07-13 17:14:23 +00:00
Owen Anderson
393d8b0a0c Begin the painful process of tearing apart the rat'ss nest that is Constants.cpp and ConstantFold.cpp.
This involves temporarily hard wiring some parts to use the global context.  This isn't ideal, but it's
the only way I could figure out to make this process vaguely incremental.

llvm-svn: 75445
2009-07-13 04:09:18 +00:00
Nick Lewycky
d3d5cfa475 Revert r75252 which was causing some crashes at compile time.
llvm-svn: 75384
2009-07-11 20:38:25 +00:00
Torok Edwin
ae8a3ff177 assert(0) -> LLVM_UNREACHABLE.
Make llvm_unreachable take an optional string, thus moving the cerr<< out of
line.
LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for
NDEBUG builds.

llvm-svn: 75379
2009-07-11 20:10:48 +00:00
Torok Edwin
9b41a5faf2 Convert more assert(0)+abort() -> LLVM_UNREACHABLE,
and abort()/exit() -> llvm_report_error().

llvm-svn: 75363
2009-07-11 13:10:19 +00:00
Dan Gohman
5749595b5b Remove ScalarEvolution::hasSCEV, which isn't being used, and which
breaks encapsulation. Also remove a dead prototype for setSCEV.

llvm-svn: 75272
2009-07-10 20:25:29 +00:00
Dan Gohman
404a92e330 Generalize ScalarEvolution's cast-folding code to support more kinds
of loops. Add several new functions to for working with ScalarEvolution's
add-hoc value-range analysis functionality.

llvm-svn: 75252
2009-07-10 16:42:52 +00:00
Dan Gohman
05e65cf9e4 Make the code that updates ScalarEvolution's internal state in response
to a loop deletion more thorough. Don't prune the def-use tree search at
instructions that don't have SCEVs computed, because an instruction with
a user that has a computed SCEV may itself lack a computed SCEV.  Also,
remove loop-related values from the ValuesAtScopes and
ConstantEvolutionLoopExitValues maps as well.

This fixes a regression in 483.xalancbmk.

llvm-svn: 75030
2009-07-08 19:23:34 +00:00
Owen Anderson
332aae685b Switch GlobalVariable ctors to a sane API, where *either* a context or a module is required.
llvm-svn: 75025
2009-07-08 19:03:57 +00:00
Nick Lewycky
d46a7b2d22 Remove the vicmp and vfcmp instructions. Because we never had a release with
these instructions, no autoupgrade or backwards compatibility support is
provided.

llvm-svn: 74991
2009-07-08 03:04:38 +00:00
Owen Anderson
7a1f69e433 Push LLVMContext through GlobalVariables and IRBuilder.
llvm-svn: 74985
2009-07-08 01:26:06 +00:00
Owen Anderson
9647245825 Re-LLVMContext-ize DebugInfo, now with less breakage.
llvm-svn: 74920
2009-07-07 17:12:53 +00:00
Dan Gohman
dd7f97c496 Change all SCEV* to SCEV *.
llvm-svn: 74918
2009-07-07 17:06:11 +00:00
Owen Anderson
cbed5c5f4b Revert part of r74873 that broke Clang's debug info generation.
llvm-svn: 74910
2009-07-07 16:31:25 +00:00
Owen Anderson
121f736d9c "LLVMContext* " --> "LLVMContext *"
llvm-svn: 74878
2009-07-06 23:00:19 +00:00
Owen Anderson
5f268720e9 Finish LLVMContext-ing lib/Analysis. This required pushing LLVMContext's through the ValueTracking API.
llvm-svn: 74873
2009-07-06 22:37:39 +00:00
Owen Anderson
ad3229d281 Thread LLVMContext through the constant folding APIs, which touches a lot of files.
llvm-svn: 74844
2009-07-06 18:42:36 +00:00
Nick Lewycky
d9573d899d When comparing constants, consider a less wide constant to be "less complex"
than a wider one, before trying to compare their contents which will crash
if their sizes are different.

llvm-svn: 74792
2009-07-04 17:24:52 +00:00
Andreas Bolka
195aca7d25 Minor improvement to the LDA debug output.
llvm-svn: 74754
2009-07-03 01:42:52 +00:00
Devang Patel
5f93a737f6 Simplify debug info intrisinc lowering.
llvm-svn: 74733
2009-07-02 22:43:26 +00:00
Devang Patel
5a12c3ba50 Fix typo.
Thanks Duncan!

llvm-svn: 74706
2009-07-02 17:17:03 +00:00
Chris Lattner
54c0359890 do not try to analyze bitcasts from i64 to <2 x i32> in ComputedMaskedBits. While
we could do this, doing so requires adjusting the demanded mask and the code isn't 
doing that yet.  This fixes PR4495

llvm-svn: 74699
2009-07-02 16:04:08 +00:00
Devang Patel
8726708137 Add debug info utility routines.
llvm-svn: 74680
2009-07-02 01:15:24 +00:00
Devang Patel
0349a19e60 Keep DIDescriptor methods together.
No functionality change.

llvm-svn: 74652
2009-07-01 22:10:23 +00:00
Andreas Bolka
3ba7d77eff Use AA to check objects before LDA.
llvm-svn: 74647
2009-07-01 21:45:23 +00:00
Chris Lattner
4bdaace06e improve the APIs for creating struct and function types with no arguments/elements
to not have to create a temporary vector (in the API at least).  Patch by Jay Foad!

llvm-svn: 74584
2009-07-01 04:13:31 +00:00
Dan Gohman
b3c5210779 Minor code cleanups.
llvm-svn: 74551
2009-06-30 20:13:32 +00:00
Owen Anderson
4b4ba9f06c Fix the build on Cygwin. Patch by Aaron Gray.
llvm-svn: 74510
2009-06-30 05:33:46 +00:00
Andreas Bolka
71ef361d1d Array accesses are independent if the underlying arrays differ.
llvm-svn: 74499
2009-06-30 02:12:10 +00:00
Dan Gohman
cb466d07fb Minor formatting, whitespace, and 80-column fixes.
llvm-svn: 74492
2009-06-30 01:25:30 +00:00
Dan Gohman
ab49c8abe9 Use getSCEV instead of getUnknown to create a SCEV for a
Constant. This lets ConstantInts be handled as SCEVConstant instead
of SCEVUnknown, as getUnknown no longer has special-case code for
ConstantInt and friends. This usually doesn't affect the final
output, since the constants end up getting folded later, but it
does make intermediate expressions more obvious in many cases.

llvm-svn: 74459
2009-06-29 21:31:18 +00:00
Dan Gohman
d496b35af0 Don't cache PHI exit values from exhaustive evaluations, because
an individual exhaustive evaluation reflects only the exit value
implied by an individual exit, which may differ from the actual
exit value of the loop if there are other exits. This fixes PR4477.

llvm-svn: 74447
2009-06-29 20:34:13 +00:00
Andreas Bolka
e9be816964 Relax LDA memory instruction checks.
llvm-svn: 74439
2009-06-29 18:51:11 +00:00
Torok Edwin
9c5c74d4ca Call doInitialization(), releaseMemory(), and doFinalization() for on-the-fly passes as well.
Also don't call finalizers for LoopPass if initialization was not called.
Add a unittest that tests that these methods are called, in the proper
order, and the correct number of times.

llvm-svn: 74438
2009-06-29 18:49:09 +00:00
Dan Gohman
011d5bd123 Simplify this code, and avoid using APInt(). This fixes
(otherwise harmless) uninitialized value warnings that
Duncan found with gcc-4.4.

llvm-svn: 74437
2009-06-29 18:25:52 +00:00
Andreas Bolka
3fd2d1c6a5 Missed one.
llvm-svn: 74416
2009-06-29 00:53:49 +00:00
Andreas Bolka
32493b35ba Fix case in LDA util function names.
llvm-svn: 74415
2009-06-29 00:50:26 +00:00
Andreas Bolka
bed5622fb7 Print pairwise dependence results, add testcases.
llvm-svn: 74402
2009-06-28 00:35:22 +00:00
Andreas Bolka
1bb3ea724e Minimal LDA interface, maximally conservative tester.
llvm-svn: 74401
2009-06-28 00:21:21 +00:00
Andreas Bolka
f31c966606 LDA analysis output scaffolding.
llvm-svn: 74400
2009-06-28 00:16:08 +00:00
Dan Gohman
e25e17d91e Eliminate a layer of indirection in LoopInfo and MachineLoopInfo.
llvm-svn: 74394
2009-06-27 21:22:48 +00:00
Dan Gohman
592d4b6ee0 Convert ScalarEvolution to use BumpPtrAllocator and FoldingSet, instead
of a team of individual allocations and a team of std::maps.

llvm-svn: 74393
2009-06-27 21:21:31 +00:00
Dan Gohman
36f9ee7670 Change SCEVExpander to use an IRBuilder to emit instructions.
llvm-svn: 74391
2009-06-27 21:18:18 +00:00
Dan Gohman
4f74e815f1 Incorporate the insertion point into the key of SCEVExpander's CSE map.
This helps it avoid reusing an instruction that doesn't dominate all
of the users, in cases where the original instruction was inserted
before all of the users were known.  This may result in redundant
expansions of sub-expressions that depend on loop-unpredictable values
in some cases, however this isn't very common, and it primarily impacts
IndVarSimplify, so GVN can be expected to clean these up.

This eliminates the need for IndVarSimplify's FixUsesBeforeDefs,
which fixes several bugs.

llvm-svn: 74352
2009-06-26 22:53:46 +00:00
Dan Gohman
9e78d55440 Fix ScalarEvolution::getAddRecExpr's code which canonicalized the
nesting order of nested AddRec expressions to skip the transformation
if it would introduce an AddRec with operands not loop-invariant
with respect to its loop.

llvm-svn: 74343
2009-06-26 22:36:20 +00:00
Dan Gohman
e8b1947a18 Fix SCEVAddRecExpr::isLoopInvariant to test if all of its operands
are loop invariant, not just the start operand.

llvm-svn: 74338
2009-06-26 22:17:21 +00:00
Douglas Gregor
6d9b0e8c19 Fix linking of llvm-ld and lli with CMake, from Xerxes Rånby
llvm-svn: 74285
2009-06-26 15:37:00 +00:00
Devang Patel
84a8914a4a Remove debug info anchors - llvm.dbg.compile_units, llvm.dbg.subprograms
and llvm.dbg.global_variables.

llvm-svn: 74251
2009-06-26 01:49:18 +00:00
Owen Anderson
e52105541d Use a more correct atomic increment style. This isn't really necessary in
this case, but it should help avoid issues in the future.

llvm-svn: 74178
2009-06-25 16:32:45 +00:00
Owen Anderson
74964377a6 Make this thread-safe.
llvm-svn: 74129
2009-06-24 22:16:52 +00:00
Owen Anderson
68b4197830 Get rid of a static boolean.
llvm-svn: 74125
2009-06-24 22:08:59 +00:00
Andreas Bolka
141dde15bb Scaffolding for LDA pass.
llvm-svn: 74120
2009-06-24 21:29:13 +00:00
Owen Anderson
90f7655f57 Get rid of the global CFGOnly flag by threading a ShortNames parameters through the GraphViz rendering code.
Update other uses in the codebase for this change.

llvm-svn: 74084
2009-06-24 17:37:09 +00:00
Dan Gohman
34b8ca6976 Minor whitespace cleanups.
llvm-svn: 74074
2009-06-24 14:49:00 +00:00
Dan Gohman
b4e1f166e1 Simplify [su]max(MAX, n) to MAX. This comes up in loop tripcount
computations in loops with multiple exits.

Adjust the testcase for PR4436 so that the relevant portion isn't
optimized away.

llvm-svn: 74073
2009-06-24 14:46:22 +00:00
Dan Gohman
19c3326fc9 Delete some orphaned comments, fix some 80-column violations,
and tidy up a few other formatting issues.

llvm-svn: 74060
2009-06-24 04:48:43 +00:00
Dan Gohman
4f4bda36df Extend ScalarEvolution's multiple-exit support to compute exact
trip counts in more cases.

Generalize ScalarEvolution's isLoopGuardedByCond code to recognize
And and Or conditions, splitting the code out into an
isNecessaryCond helper function so that it can evaluate Ands and Ors
recursively, and make SCEVExpander be much more aggressive about
hoisting instructions out of loops.

test/CodeGen/X86/pr3495.ll has an additional instruction now, but
it appears to be due to an arbitrary register allocation difference.

llvm-svn: 74048
2009-06-24 01:18:18 +00:00
Dan Gohman
6f0aa30f94 Teach GetMinSignBits about SCEVAddExprs.
llvm-svn: 74045
2009-06-24 01:05:09 +00:00
Dan Gohman
3bf5d76081 Move the special cases for constants out of getUnknown and into
createSCEV. Also, recognize UndefValue in createSCEV.

Change getIntegerSCEV's comment to avoid mentioning FP types,
and re-implement it in terms of getConstant instead of getUnknown.

llvm-svn: 74041
2009-06-24 00:54:57 +00:00
Dan Gohman
0a2dbfc356 Use ScalarEvolution::getConstant instead of getUnknown to create
SCEVConstants. This cleanup is a step toward letting getUnknown
be simpler.

llvm-svn: 74037
2009-06-24 00:38:39 +00:00
Dan Gohman
774c9da9c6 Include the maximum trip count expression in ScalarEvolution's print output.
llvm-svn: 74035
2009-06-24 00:33:16 +00:00
Dan Gohman
9ccdc738a9 Add an isAllOnesValue utility function, similar to isZero and isOne.
llvm-svn: 74032
2009-06-24 00:30:26 +00:00
Devang Patel
5fe5a578c7 It is not a good idea to have data member's name match argument's name. In fact, it is a simple receipe to waste an hour or so.
llvm-svn: 74018
2009-06-23 22:25:41 +00:00
Devang Patel
72bc2b09af Use getReturnTypeName() to print return type.
llvm-svn: 74017
2009-06-23 22:23:13 +00:00
Dan Gohman
058143a236 Fix a bug in the trip-count computation with And/Or. If either of the
sides is CouldNotCompute, the resulting exact count must be CouldNotCompute.

llvm-svn: 73920
2009-06-22 23:28:56 +00:00
Owen Anderson
3c420a892f Remove unneeded #include.
llvm-svn: 73911
2009-06-22 22:09:07 +00:00
Dan Gohman
b4f58ad636 Fix a few minor issues that were exposed by the removal of SCEVHandle.
llvm-svn: 73910
2009-06-22 22:08:45 +00:00
Dan Gohman
b85ac02513 Fix llvm::ComputeNumSignBits to handle pointer types
conservatively correctly, instead of aborting.

llvm-svn: 73908
2009-06-22 22:02:32 +00:00
Owen Anderson
422b2c613b Remove the parent pointer from SCEV, since it did not end up being needed.
llvm-svn: 73907
2009-06-22 21:57:23 +00:00
Owen Anderson
c023151c9f SCEVHandle is no more!
llvm-svn: 73906
2009-06-22 21:39:50 +00:00
Dan Gohman
54899b84bc Fix some typos that Duncan noticed.
llvm-svn: 73903
2009-06-22 21:10:22 +00:00
Owen Anderson
83b6bbdcb4 Banish global state from ScalarEvolution! SCEV uniquing is now done by tables attached to the ScalarEvolution pass.
This also throws out the SCEV reference counting scheme, as the the SCEVs now have a lifetime controlled by the
ScalarEvolution pass.

Note that SCEVHandle is now a no-op, and will be remove in a future commit.

llvm-svn: 73892
2009-06-22 18:25:46 +00:00
Dan Gohman
30b38faa05 Make use of getUMinFromMismatchedTypes when computing backedge-taken
counts for loops with multiple exits, replacing more conservative code
which only handled constants. This is derived from a patch by
Nick Lewycky.

This also fixes llc aborts in ClamAV and others, as
getUMinFromMismatchedTypes takes care of balancing the types before
working with them.

llvm-svn: 73884
2009-06-22 15:09:28 +00:00
Dan Gohman
cc245913e3 Add a getUMinFromMismatchedTypes helper function.
llvm-svn: 73883
2009-06-22 15:03:27 +00:00
Dan Gohman
d65752db50 Factor out code for computing umin and smin for SCEV expressions into
helper functions. Based on a patch by Nick Lewycky.

llvm-svn: 73869
2009-06-22 03:18:45 +00:00
Dan Gohman
db7860aa40 Teach ScalarEvolution how to analyze loops with multiple exit
blocks, and also exit blocks with multiple conditions (combined
with (bitwise) ands and ors). It's often infeasible to compute an
exact trip count in such cases, but a useful upper bound can often
be found.

llvm-svn: 73866
2009-06-22 00:31:57 +00:00
Dan Gohman
b2c544ddbd Delete an unused variable.
llvm-svn: 73865
2009-06-22 00:19:17 +00:00
Dan Gohman
eb0a67278b Fix ScalarEvolution's backedge-taken count computations to check for
overflow when computing a integer division to round up.

Thanks to Nick Lewycky for noticing this!

llvm-svn: 73862
2009-06-21 23:46:38 +00:00
Dan Gohman
29100270c0 Generalize isLoopGuardedByCond's checking to consider two
SCEVUnknowns with identical Instructions to be equal. This allows
it to analze cases such as the attached testcase, where the front-end
has cloned the loop controlling expression. Along with r73805, this
lets IndVarSimplify eliminate all the sign-extend casts in the
loop in the attached testcase.

llvm-svn: 73807
2009-06-20 00:35:32 +00:00
Dan Gohman
074c629d46 Use ScalarEvolution's new GetMinSignBits and GetMinLeadingZeros
in the loop backedge-taken count computation of the maximum
possible trip count.

llvm-svn: 73805
2009-06-20 00:32:22 +00:00
Dan Gohman
d3c3963eea Make GetMinTrailingZeros a member function of ScalarEvolution,
so that it can access the TargetData member (when available) and
use ValueTracking.h information to compute information for
SCEVUnknown Values.

Also add GetMinLeadingZeros and GetMinSignBits functions,
with minimal implementations.

llvm-svn: 73794
2009-06-19 23:29:04 +00:00
Dan Gohman
c71421c97e Make ScalarEvolution::print print getSCEVAtScope values for
expressions, when interesting.

llvm-svn: 73776
2009-06-19 17:49:54 +00:00
Dan Gohman
d920fdb643 Don't (unconditionally) use getSCEVAtScope to simplify the step
expression in IVUsers, because in the case of a use of a non-linear
addrec outside of a loop, this causes the addrec to be evaluated as
a linear addrec.

llvm-svn: 73774
2009-06-19 17:33:15 +00:00
Owen Anderson
99dc404fc5 Add a parent pointer to SCEV, in preparation for getting rid of the global uniquing tables. No functionality change.
llvm-svn: 73728
2009-06-18 22:25:12 +00:00
Dan Gohman
cc9634d988 Recognize n != 0 ? n : 1 as umax(n, 1). Previously only ULT/UGT/ULE/UGE
comparisons were recognized for umax, but instcombine canonicalizes
unsigned comparisons with zero to this simpler form.

llvm-svn: 73717
2009-06-18 20:21:07 +00:00
Dan Gohman
fd857b0406 Remove the code from IVUsers that attempted to handle
casted induction variables in cases where the cast
isn't foldable. It ended up being a pessimization in
many cases. This could be fixed, but it would require
a bunch of complicated code in IVUsers' clients. The
advantages of this approach aren't visible enough to
justify it at this time.

llvm-svn: 73706
2009-06-18 16:54:06 +00:00
Dan Gohman
b426c5dd35 Update a comment to reflect the code.
llvm-svn: 73704
2009-06-18 16:24:47 +00:00
Dan Gohman
9b236593c3 Fix trailing whitespace from ScalarEvolution::print.
llvm-svn: 73666
2009-06-18 00:37:45 +00:00
Dan Gohman
e72fd546a2 Teach ScalarEvolution how to recognize another xor(and(x, C), C) case.
If C is a single bit and the and gets analyzed as a truncate and
zero-extend, the xor can be represnted as an add.

llvm-svn: 73664
2009-06-18 00:00:20 +00:00
Dan Gohman
eb8d3f5fd5 Delete unnecessary braces.
llvm-svn: 73663
2009-06-17 23:54:37 +00:00
Dan Gohman
473789f75a Fix ScalarEvolution's Xor handling to not assume that an And
that gets recognized with a SCEVZeroExtendExpr must be an And
with a low-bits mask. With r73540, this is no longer the case.

llvm-svn: 73594
2009-06-17 01:22:39 +00:00
Dan Gohman
56b5a88785 Instcombine's ShrinkDemandedConstant may strip bits out of constants,
obscuring what would otherwise be a low-bits mask.  Use ComputeMaskedBits
to compute what ShrinkDemandedConstant knew about to reconstruct a
low-bits mask value.

llvm-svn: 73540
2009-06-16 19:52:01 +00:00
Dan Gohman
2e737ac21f Support vector casts in more places, fixing a variety of assertion
failures.

To support this, add some utility functions to Type to help support
vector/scalar-independent code. Change ConstantInt::get and
ConstantFP::get to support vector types, and add an overload to
ConstantInt::get that uses a static IntegerType type, for
convenience.

Introduce a new getConstant method for ScalarEvolution, to simplify
common use cases.

llvm-svn: 73431
2009-06-15 22:12:54 +00:00
Dan Gohman
deff76f526 Code cleanups. getSCEVAtScope no longer uses SCEVCouldNotCompute.
llvm-svn: 73401
2009-06-15 18:38:59 +00:00
Dan Gohman
111f127d23 Fix old-style type names in comments.
llvm-svn: 73362
2009-06-14 23:30:43 +00:00
Dan Gohman
d3a8d79c0d Implement more aggressive folding of add operand lists when
they contain multiplications of constants with add operations.
This helps simplify several kinds of things; in particular it
helps simplify expressions like ((-1 * (%a + %b)) + %a) to %b,
as expressions like this often come up in loop trip count
computations.

llvm-svn: 73361
2009-06-14 22:58:51 +00:00
Dan Gohman
bee566c1ce Check for the short-circuiting condition before performing
the potentially expensive erase.

llvm-svn: 73359
2009-06-14 22:53:57 +00:00
Dan Gohman
d1c7be715c Do compare constant SCEV values in SCEVComplexityCompare, because
even though the order doesn't matter at the top level of an expression,
it does matter when the constant is a subexpression of an n-ary
expression, because n-ary expressions are sorted lexicographically.

llvm-svn: 73358
2009-06-14 22:51:25 +00:00
Dan Gohman
d895ed43c8 Convert several parts of the ScalarEvolution framework to use
SmallVector instead of std::vector.

llvm-svn: 73357
2009-06-14 22:47:23 +00:00
Dan Gohman
37fef35e88 Teach SCEVExpander's visitAddRecExpr to reuse an existing canonical
induction variable when the addrec to be expanded does not require
a wider type. This eliminates the need for IndVarSimplify to
micro-manage SCEV expansions, because SCEVExpander now
automatically expands them in the form that IndVarSimplify considers
to be canonical. (LSR still micro-manages its SCEV expansions,
because it's optimizing for the target, rather than for
other optimizations.)

Also, this uses the new getAnyExtendExpr, which has more clever
expression simplification logic than the IndVarSimplify code it
replaces, and this cleans up some ugly expansions in code such as
the included masked-iv.ll testcase.

llvm-svn: 73294
2009-06-13 16:25:49 +00:00
Dan Gohman
25827fdc12 Add a ScalarEvolution::getAnyExtendExpr utility function for performing
extension with unspecified bits.

llvm-svn: 73293
2009-06-13 15:56:47 +00:00
Dan Gohman
389d27ecdd Use expandCodeFor instead of expand when the result will be
immediately casted. At present, this is just a minor code
simplification. In the future, the expansion code may be able
to make better choices if it knows what the desired result
type will be.

llvm-svn: 73137
2009-06-09 17:18:38 +00:00
Dan Gohman
5470ba421d Rename UnknownValue to CouldNotCompute, since it holds an instance of
SCEVCouldNotCompute, and not SCEVUnknown.

llvm-svn: 72999
2009-06-06 14:37:11 +00:00
Devang Patel
a6b3b19170 Simplify.
llvm-svn: 72970
2009-06-05 23:08:56 +00:00
Dan Gohman
856e18c047 Move SCEVExpander::getOrInsertCanonicalInductionVariable out of line.
llvm-svn: 72949
2009-06-05 16:35:53 +00:00
Dan Gohman
ee407d25ca Remove some unnecessary #includes.
llvm-svn: 72948
2009-06-05 16:32:58 +00:00
Dan Gohman
5f6f8101d5 Split the Add, Sub, and Mul instruction opcodes into separate
integer and floating-point opcodes, introducing
FAdd, FSub, and FMul.

For now, the AsmParser, BitcodeReader, and IRBuilder all preserve
backwards compatability, and the Core LLVM APIs preserve backwards
compatibility for IR producers. Most front-ends won't need to change
immediately.

This implements the first step of the plan outlined here:
http://nondot.org/sabre/LLVMNotes/IntegerOverflow.txt

llvm-svn: 72897
2009-06-04 22:49:04 +00:00
Dan Gohman
d1f2f34c1a Change ConstantFoldConstantExpression to accept a null
TargetData pointer. The only thing it's used for are
calls to ConstantFoldCompareInstOperands and
ConstantFoldInstOperands, which both already accept a
null TargetData pointer. This makes
ConstantFoldConstantExpression easier to use in clients
where TargetData is optional.

llvm-svn: 72741
2009-06-02 21:48:15 +00:00
Dan Gohman
0e4b3c0955 Delete an obsolete sentance from a comment.
llvm-svn: 72667
2009-05-31 16:18:57 +00:00
Dan Gohman
491de1fe7e Add braces around an array initializer.
llvm-svn: 72453
2009-05-27 02:07:15 +00:00
Dan Gohman
0124c21ba0 Teach SCEVExpander to avoid creating over-indexed GEP indices when
possible. For example, it now emits

  %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 2, i64 %tmp, i64 1

instead of the equivalent but less obvious

  %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 %tmp, i64 19

llvm-svn: 72452
2009-05-27 02:00:53 +00:00
Dan Gohman
5dd6f54a5f Teach BasicAliasAnalysis to understand constant gep indices that fall
beyond their associated static array type.

I believe that this fixes a legitimate bug, because BasicAliasAnalysis
already has code to check for this condition that works for non-constant
indices, however it was missing the case of constant indices. With this
change, it checks for both.

This fixes PR4267, and miscompiles of SPEC 188.ammp and 464.h264.href.

llvm-svn: 72451
2009-05-27 01:48:27 +00:00
Dan Gohman
5003d0ee42 For the return type of SCEVUDivExpr, use the RHS' type instead of
that of the LHS. It doesn't matter for correctness, but the LHS
is more likely than the RHS to be a pointer type in exotic cases,
and it's more tidy to have it return the integer type.

llvm-svn: 72424
2009-05-26 17:44:05 +00:00
Dan Gohman
fb34a67498 In cases where a pointer value is an operand of a multiplication or
division operation, don't attempt to use the operation's value as
the base of a getelementptr. This fixes PR4271.

llvm-svn: 72422
2009-05-26 17:41:16 +00:00
Chris Lattner
8f4210d099 make memdep use the getModRefInfo method for stores instead of the
low-level alias() method, allowing it to reason more aggressively
about pointers into constant memory.  PR4189

llvm-svn: 72403
2009-05-25 21:28:56 +00:00
Dan Gohman
621071c6c4 Various comment fixes.
llvm-svn: 72376
2009-05-24 23:45:28 +00:00
Dan Gohman
19be1fa810 Change ScalarEvolution::getSCEVAtScope to always return the original value
in the case where a loop exit value cannot be computed, instead of only in
some cases while using SCEVCouldNotCompute in others. This simplifies
getSCEVAtScope's callers.

llvm-svn: 72375
2009-05-24 23:25:42 +00:00
Torok Edwin
aca641232c Instead of clearing the rewriter, don't attempt to rewrite dead phi nodes.
Also fix 80 column violation.

llvm-svn: 72371
2009-05-24 19:36:09 +00:00
Dan Gohman
942daf73f8 Fix this code for hosts where std::vector doesn't have .data().
Use &Ops[0] instead, which is safe since Ops will never be empty here.

llvm-svn: 72368
2009-05-24 19:02:45 +00:00
Dan Gohman
fdba9c8fce Generalize SCEVExpander::visitAddRecExpr's GEP persuit, and avoid
sending SCEVUnknowns to expandAddToGEP. This avoids the need for
expandAddToGEP to bend the rules and peek into SCEVUnknown
expressions.

Factor out the code for testing whether a SCEV can be factored by
a constant for use in a GEP index. This allows it to handle
SCEVAddRecExprs, by recursing.

As a result, SCEVExpander can now put more things in GEP indices,
so it emits fewer explicit mul instructions.

llvm-svn: 72366
2009-05-24 18:06:31 +00:00
Dan Gohman
378152d9d0 When the low bits of one operand of an add are zero, that number
of low bits of the other operand are preserved in the output.

llvm-svn: 72365
2009-05-24 18:02:35 +00:00
Torok Edwin
8936fc2e28 The rewriter may hold references to instructions that are deleted because they are trivially dead.
Fix by clearing the rewriter cache before deleting the trivially dead
instructions.
Also make InsertedExpressions use an AssertingVH to catch these
bugs easier.

llvm-svn: 72364
2009-05-24 14:23:16 +00:00
Dan Gohman
82df35a657 Fix a thinko in the code that adapted SCEVMulExpr operands for
use in expanding SCEVAddExprs with GEPs. The operands of a
SCEVMulExpr need to be multiplied together, not added.

llvm-svn: 72250
2009-05-22 07:14:20 +00:00
Jay Foad
16d48d2595 Use v.data() instead of &v[0] when SmallVector v might be empty.
llvm-svn: 72210
2009-05-21 09:52:38 +00:00
Dan Gohman
fc28858d91 Teach ValueTracking a new way to analyze PHI nodes, and and teach
Instcombine to be more aggressive about using SimplifyDemandedBits
on shift nodes. This allows a shift to be simplified to zero in the
included test case.

llvm-svn: 72204
2009-05-21 02:28:33 +00:00
Dan Gohman
18580e593a Teach SCEV::isLoopInvariant and SCEV::hasComputableLoopEvolution
about the convention from LoopInfo that a null Loop* means the entire
function body.

llvm-svn: 72152
2009-05-20 01:01:24 +00:00
Dan Gohman
be817680b8 Make SCEVCallbackVH a private nested class inside ScalarEvolution, as
it's an implementation detail.

llvm-svn: 72122
2009-05-19 19:22:47 +00:00
Dan Gohman
f61ddb4c06 Create ConstantExpr GEPs the correct way. This fixes
MultiSource/Benchmarks/Prolangs-C/football and a variety of other
failures.

llvm-svn: 72120
2009-05-19 19:18:01 +00:00
Dan Gohman
922033d119 Teach SCEVExpander to expand arithmetic involving pointers into GEP
instructions. It attempts to create high-level multi-operand GEPs,
though in cases where this isn't possible it falls back to casting
the pointer to i8* and emitting a GEP with that. Using GEP instructions
instead of ptrtoint+arithmetic+inttoptr helps pointer analyses that
don't use ScalarEvolution, such as BasicAliasAnalysis.

Also, make the AddrModeMatcher more aggressive in handling GEPs.
Previously it assumed that operand 0 of a GEP would require a register
in almost all cases. It now does extra checking and can do more
matching if operand 0 of the GEP is foldable. This fixes a problem
that was exposed by SCEVExpander using GEPs.

llvm-svn: 72093
2009-05-19 02:15:55 +00:00
Daniel Dunbar
7c5aee4f79 Silence Release-Asserts warnings.
llvm-svn: 72011
2009-05-18 16:43:04 +00:00
Dan Gohman
592d65ba06 Teach ScalarEvolution to recognize x^-1 in the case where non-demanded
bits have been stripped out by instcombine.

llvm-svn: 72010
2009-05-18 16:29:04 +00:00
Dan Gohman
09726e69b9 Delete a redundant 'else'.
llvm-svn: 72009
2009-05-18 16:17:44 +00:00
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
Bill Wendling
78f6980946 Non-functionality changes:
- Reformatting.
- Use while() instead of do-while().
- Move simple constructors into .h file.

llvm-svn: 71782
2009-05-14 18:26:15 +00:00
Bill Wendling
3449db3f16 Clean up this file fixing 80-column violations, bad formatting, etc. No functionality change.
llvm-svn: 71781
2009-05-14 18:16:46 +00:00
Duncan Sands
6f8d5b489a Avoid getting a compiler warning
IVUsers.cpp: In member function ‘bool llvm::IVUsers::AddUsersIfInteresting(llvm::Instruction*)’:
 IVUsers.cpp:221: warning: ‘isSigned’ may be used uninitialized in this function
with gcc-4.3.

llvm-svn: 71654
2009-05-13 12:52:44 +00:00
Chris Lattner
a5add81e91 add IVUsers.cpp
llvm-svn: 71646
2009-05-13 06:28:04 +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
d13f674130 Factor the code for collecting IV users out of LSR into an IVUsers class,
and generalize it so that it can be used by IndVarSimplify. Implement the
base IndVarSimplify transformation code using IVUsers. This removes
TestOrigIVForWrap and associated code, as ScalarEvolution now has enough
builtin overflow detection and folding logic to handle all the same cases,
and more. Run "opt -iv-users -analyze -disable-output" on your favorite
loop for an example of what IVUsers does.

This lets IndVarSimplify eliminate IV casts and compute trip counts in
more cases. Also, this happens to finally fix the remaining testcases
in PR1301.

Now that IndVarSimplify is being more aggressive, it occasionally runs
into the problem where ScalarEvolutionExpander's code for avoiding
duplicate expansions makes it difficult to ensure that all expanded
instructions dominate all the instructions that will use them. As a
temporary measure, IndVarSimplify now uses a FixUsesBeforeDefs function
to fix up instructions inserted by SCEVExpander. Fortunately, this code
is contained, and can be easily removed once a more comprehensive
solution is available.

llvm-svn: 71535
2009-05-12 02:17:14 +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
Bill Wendling
5de4207c68 Print out nicer dump info for DIDescriptor.
llvm-svn: 71253
2009-05-08 20:28:06 +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
ebacd61d7d Revert 71165. It did more than just revert 71158 and it introduced
several regressions. The problem due to 71158 is now fixed.

llvm-svn: 71176
2009-05-07 19:46:24 +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
Duncan Sands
e90202e388 Revert r70876 and add a testcase (@c7) showing the problem:
bits captured, but the pointer marked nocapture.  In fact
I now recall that this problem is why only readnone functions
returning void were considered before!  However keep a small
fix that was also in r70876: a readnone function returning
void can result in bits being captured if it unwinds, so
test for this.

llvm-svn: 71168
2009-05-07 18:08:34 +00:00
Bill Wendling
9f97e4a3dc Temporarily revert r71158. It was causing a failure during a full bootstrap:
checking for bcopy... no
checking for getc_unlocked... Assertion failed: (0 && "Unknown SCEV kind!"), function operator(), file /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore.roots/llvmCore~obj/src/lib/Analysis/ScalarEvolution.cpp, line 511.
/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/llvmgcc42~obj/src/libdecnumber/decUtility.c:360: internal compiler error: Abort trap
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.
make[4]: *** [decUtility.o] Error 1
make[4]: *** Waiting for unfinished jobs....
Assertion failed: (0 && "Unknown SCEV kind!"), function operator(), file /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore.roots/llvmCore~obj/src/lib/Analysis/ScalarEvolution.cpp, line 511.
/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/llvmgcc42~obj/src/libdecnumber/decNumber.c:5591: internal compiler error: Abort trap
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.
make[4]: *** [decNumber.o] Error 1
make[3]: *** [all-stage2-libdecnumber] Error 2
make[3]: *** Waiting for unfinished jobs....

llvm-svn: 71165
2009-05-07 17:26:14 +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
9a6a882979 Constant-fold ptrtoint+add+inttoptr to gep when the pointer is an
array and the add is within range. This helps simplify expressions
expanded by ScalarEvolutionExpander.

llvm-svn: 71158
2009-05-07 14:24:56 +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
Bill Wendling
265f9ffc43 Add dump method to DIDescriptor.
llvm-svn: 71028
2009-05-05 22:19:25 +00:00
Chris Lattner
a96ef42a06 Do not require variable debug info nodes to have a compile unit.
For implicit decls like "self" and "_cmd" in ObjC, these decls
should not have a location.

llvm-svn: 70964
2009-05-05 04:55:56 +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
Duncan Sands
4c7021febf Teach capture tracking that readonly functions can
only capture their arguments by returning them or
throwing an exception or not based on the argument
value.  Patch essentially by Frits van Bommel.

llvm-svn: 70876
2009-05-04 16:50:29 +00:00
Argyrios Kyrtzidis
a034549d67 -Move the DwarfWriter::ValidDebugInfo check to a static DIDescriptor::ValidDebugInfo
-Create DebugLocs without the need to have a DwarfWriter around

llvm-svn: 70682
2009-05-03 08:50:41 +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
6aa1fd5065 Change the description string of the LoopInfo pass.
"Construction" makes it sound like a pass that might
modify the CFG to construct natural loops.

llvm-svn: 70580
2009-05-01 21:58:05 +00:00
Dan Gohman
d57099a9eb Actually insert inserted instructions into the InsertedValues map.
llvm-svn: 70557
2009-05-01 17:13:31 +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
bc336eab6e Short-circuit inttoptr-ptrtoint constant expressions; these aren't
always folded by the regular constant folder because it doesn't have
TargetData information.

llvm-svn: 70553
2009-05-01 17:00:00 +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
Dan Gohman
c0f47d6ec1 Change SCEVExpander's expandCodeFor to provide more flexibility
with the persistent insertion point, and change IndVars to make
use of it. This fixes a bug where IndVars was holding on to a
stale insertion point and forcing the SCEVExpander to continue to
use it.

This fixes PR4038.

llvm-svn: 69892
2009-04-23 15:16:49 +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
Devang Patel
7daece3796 Fix cut-n-pasto.
llvm-svn: 69816
2009-04-22 18:51:05 +00:00
Dan Gohman
d6edb69103 Simplify trivial cast-of-cast SCEVs.
llvm-svn: 69809
2009-04-22 16:20:48 +00:00
Dan Gohman
0ab6ecf6a1 SCEVExpander's InsertCastOfTo knows how to move existing cast
instructions in order to avoid inserting new ones. However, if
the cast instruction is the SCEVExpander's InsertPt, this
causes subsequently emitted instructions to be inserted near
the cast, and not at the location of the original insert point.
Fix this by adjusting the insert point in such cases.
This fixes PR4009.

llvm-svn: 69808
2009-04-22 16:11:16 +00:00
Dan Gohman
471996598f Use BasicBlock::iterator instead of Instruction* for insert points,
to better handle inserting instructions at the end of a block.

llvm-svn: 69807
2009-04-22 16:05:50 +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
Dan Gohman
19990f2310 When turning (ashr(shl(x, n), n)) into sext(trunc(x)), the width of the
type to truncate to should be the number of bits of the value that are
preserved, not the number that are clobbered with sign-extension.
This fixes regressions in ldecod.

llvm-svn: 69704
2009-04-21 20:18:36 +00:00
Dan Gohman
5cf1e72db9 Teach ScalarEvolution how to recognize zext-inreg and sext-inreg,
as they appear in LLVM IR. This isn't particularly interesting
on its own; this is just setting up some infrastructure.

llvm-svn: 69655
2009-04-21 02:26:00 +00:00
Dan Gohman
f920d0a020 This FIXME is fixed, now that SCEV understands pointers.
llvm-svn: 69651
2009-04-21 01:41:18 +00:00
Dan Gohman
4e3e945880 Factor out a common base class from SCEVTruncateExpr, SCEVZeroExtendExpr,
and SCEVSignExtendExpr.

llvm-svn: 69649
2009-04-21 01:25:57 +00:00
Dan Gohman
2f8d813b3a Usage getAnalysisToUpdate for TargetData, per PR760.
llvm-svn: 69645
2009-04-21 01:11:19 +00:00
Dan Gohman
55d8490e7b Introduce encapsulation for ScalarEvolution's TargetData object, and refactor
the code to minimize dependencies on TargetData.

llvm-svn: 69644
2009-04-21 01:07:12 +00:00
Dan Gohman
5665fdf2e3 Move some assertion checks so they can do more complete checking.
llvm-svn: 69643
2009-04-21 00:55:22 +00:00
Dan Gohman
dd1bfdc7b1 Convert ScalarEvolution to use raw_ostream instead of OStream.
llvm-svn: 69640
2009-04-21 00:47:46 +00:00
Dan Gohman
f691991a39 Add a ScalarEvolution::getCouldNotCompute() function, and use it
instead of allocating and leaking new SCEVCouldNotCompute objects.

llvm-svn: 69452
2009-04-18 17:58:19 +00:00