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

2405 Commits

Author SHA1 Message Date
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