Commit Graph

459 Commits

Author SHA1 Message Date
Dan Gohman
a5145c8d5a Fix SCEVCommutativeExpr::print to be robust in the case of improper
expression canonicalization. Its job is to print what's there, not to
make judgements about it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101461 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-16 15:03:25 +00:00
Dan Gohman
005752bbe7 Make getPredecessorWithUniqueSuccessorForBB return the unique successor
in addition to the predecessor.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101374 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15 16:19:08 +00:00
Dan Gohman
2c93e39072 Add a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-14 16:08:56 +00:00
Dan Gohman
28287794d4 Teach ScalarEvolution to simplify smax and umax when it can prove
that one operand is always greater than another.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101142 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-13 16:51:03 +00:00
Dan Gohman
3ab131243e Minor code micro-optimizations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101141 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-13 16:49:23 +00:00
Dan Gohman
bca091d561 Micro-optimize a few hot spots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101086 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-12 23:08:18 +00:00
Dan Gohman
6ab10f69a9 Add fast paths to ScalarEvolution::getSizeOf and getOffsetOf, as
they're used a lot by getNodeForGEP, which can be called a lot.
This speeds up -iv-users by around 15% on several testcases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101083 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-12 23:03:26 +00:00
Dan Gohman
27dead44e0 Generalize ScalarEvolution's PHI analysis to handle loops that don't
have preheaders or dedicated exit blocks, as clients may not otherwise
need to run LoopSimplify.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101030 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-12 07:49:36 +00:00
Dan Gohman
646e047765 Rewrite the overflow checking in the get{Signed,Unsigned}Range code for
AddRecs so that it checks for overflow in the computation that it is
performing, rather than just checking hasNo{Signed,Unsigned}Wrap, since
those flags are for a different computation. This fixes a bug that
impacts an upcoming change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101028 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-12 07:39:33 +00:00
Dan Gohman
5ee60f7508 Fix indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101001 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11 23:44:58 +00:00
Dan Gohman
53c66eacc4 Enhance ScalarEvolution::isKnownPredicate with support for
loop conditions which are invariants.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100995 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11 22:16:48 +00:00
Dan Gohman
b64cf896f8 Minor code simplification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100994 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11 22:13:11 +00:00
Dan Gohman
bc7129f9db When creating a ConstantRange for [n,UINT_MAX], special case n == 0, because
ConstantRange(0, 0) creates an empty range rather than a full one.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100993 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11 22:12:18 +00:00
Dan Gohman
3948d0b8b0 Rename isLoopGuardedByCond to isLoopEntryGuardedByCond, to emphasise
that it's only testing for the entry condition, not full loop-invariant
conditions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100979 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11 19:27:13 +00:00
Dan Gohman
e056781323 Add variants of ult, ule, etc. which take a uint64_t RHS, for convenience.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100824 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08 23:03:40 +00:00
Dan Gohman
8ef5caa80a Revert this change from a while ago; ScalarEvolution shouldn't analyze
undef as 0, since it can't force other analyses to intepret the undef
in the same way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100749 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08 05:58:24 +00:00
Dan Gohman
9553188fcc Define placement new wrappers for BumpPtrAllocator and
RecyclingAllocator to allow client code to be simpler, and
simplify several clients.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98847 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 18:49:47 +00:00
Dan Gohman
c93b4cff89 Add the ability to "intern" FoldingSetNodeID data into a
BumpPtrAllocator-allocated region to allow it to be stored in a more
compact form and to avoid the need for a non-trivial destructor call.

Use this new mechanism in ScalarEvolution instead of
FastFoldingSetNode to avoid leaking memory in the case where a
FoldingSetNodeID uses heap storage, and to reduce overall memory
usage.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98829 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 16:16:38 +00:00
Dan Gohman
f9e64729af Reapply r98755 with a thinko which miscompiled gengtype fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98793 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 01:17:13 +00:00
Dan Gohman
ebf78f18df Revert 98755, which may be causing trouble.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98762 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-17 19:54:53 +00:00
Dan Gohman
0afc29c3e6 Change SCEVNAryExpr's operand array from a SmallVector to a plain
pointer and length, and allocate the arrays in ScalarEvolution's
BumpPtrAllocator, so that they get released when their owning
SCEV gets released. SCEVs are immutable, so they don't need to worry
about operand array resizing. This fixes a memory leak reported
in PR6637.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98755 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-17 18:51:01 +00:00
Dan Gohman
4ecbca558f Avoid analyzing instructions in blocks not reachable from the entry block.
They are lots of trouble, and they don't matter. This fixes PR6559.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98103 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-09 23:46:50 +00:00
Dan Gohman
3f46a3abee Spelling fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97453 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01 17:49:51 +00:00
Dan Gohman
8566963713 Make LoopSimplify change conditional branches in loop exiting blocks
which branch on undef to branch on a boolean constant for the edge
exiting the loop. This helps ScalarEvolution compute trip counts for
loops.

Teach ScalarEvolution to recognize single-value PHIs, when safe, and
ForgetSymbolicName to forget such single-value PHI nodes as apprpriate
in ForgetSymbolicName.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97126 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25 06:57:05 +00:00
Dan Gohman
e177c9a9bc ConstantFoldInstOperands can theoretically return null if it
didn't fold anything.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97049 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24 19:31:47 +00:00
Dan Gohman
8f767d987f Simplify this code; these casts aren't necessary.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97048 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24 19:31:06 +00:00
Dan Gohman
f6d009fb6f Convert a few more backedge-taken count functions to use BackedgeTakenInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97042 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24 17:31:30 +00:00
Dan Gohman
454d26dc43 Remove unused variables and parameters.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96780 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-22 04:11:59 +00:00
Dan Gohman
bc02853b89 Add a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96688 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19 18:49:22 +00:00
Dan Gohman
00cb5b7245 Teach ScalarEvolution how to compute a tripcount for a loop with
true or false as its exit condition. These are usually eliminated by
SimplifyCFG, but the may be left around during a pass which wishes
to preserve the CFG.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96683 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19 18:12:07 +00:00
Dale Johannesen
45a2d7d44a recommit 96626, evidence that it broke things appears
to be spurious



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96662 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19 07:14:22 +00:00
Dale Johannesen
efd9e95051 Revert 96626, which causes build failure on ppc Darwin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96653 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19 01:54:37 +00:00
Dan Gohman
aa11defd1c Indvars needs to explicitly notify ScalarEvolution when it is replacing
a loop exit value, so that if a loop gets deleted, ScalarEvolution
isn't stick holding on to dangling SCEVAddRecExprs for that loop. This
fixes PR6339.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96626 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 23:26:33 +00:00
Duncan Sands
1df9859c40 There are two ways of checking for a given type, for example isa<PointerType>(T)
and T->isPointerTy().  Convert most instances of the first form to the second form.
Requested by Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96344 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 11:11:14 +00:00
Duncan Sands
b0bc6c361d Uniformize the names of type predicates: rather than having isFloatTy and
isInteger, we now have isFloatTy and isIntegerTy.  Requested by Chris!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96223 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-15 16:12:20 +00:00
Dan Gohman
50922bbe74 When testing whether a given SCEV depends on a temporary symbolic
name, test whether the SCEV itself is that temporary symbolic name,
in addition to checking whether the symbolic name appears as a
possibly-indirect operand.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96216 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-15 10:28:37 +00:00
Dan Gohman
39125d8ef9 Override dominates and properlyDominates for SCEVAddRecExpr, as a
SCEVAddRecExpr doesn't necessarily dominate blocks merely dominated
by all of its operands. This fixes an abort compiling 403.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96056 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-13 00:19:39 +00:00
Dan Gohman
f451cb870e Fix "the the" and similar typos.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95781 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-10 16:03:48 +00:00
Dan Gohman
32efba698d Change the argument to getIntegerSCEV to be an int64_t, rather
than int. This will make it more convenient for LSR, which does
a lot of things with int64_t offsets.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95281 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-04 02:43:51 +00:00
Dan Gohman
8db08df5d3 Various code simplifications.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95044 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 01:38:49 +00:00
Dan Gohman
4f8eea82d8 Generalize target-independent folding rules for sizeof to handle more
cases, and implement target-independent folding rules for alignof and
offsetof. Also, reassociate reassociative operators when it leads to
more folding.

Generalize ScalarEvolution's isOffsetOf to recognize offsetof on
arrays. Rename getAllocSizeExpr to getSizeOfExpr, and getFieldOffsetExpr
to getOffsetOfExpr, for consistency with analagous ConstantExpr routines.

Make the target-dependent folder promote GEP array indices to
pointer-sized integers, to make implicit casting explicit and exposed
to subsequent folding.

And add a bunch of testcases for this new functionality, and a bunch
of related existing functionality.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94987 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-01 18:27:38 +00:00
Dan Gohman
0f5efe5625 Remove SCEVAllocSizeExpr and SCEVFieldOffsetExpr, and in their place
use plain SCEVUnknowns with ConstantExpr::getSizeOf and
ConstantExpr::getOffsetOf constants. This eliminates a bunch of
special-case code.

Also add code for pattern-matching these expressions, for clients that
want to recognize them.

Move ScalarEvolution's logic for expanding array and vector sizeof
expressions into an element count times the element size, to expose
the multiplication to subsequent folding, into the regular constant
folder.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94737 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-28 02:15:55 +00:00
Dan Gohman
c9c36cb3d9 Make the unsigned-range code more consistent with the signed-range code,
and clean up some loose ends.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94572 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 19:19:05 +00:00
Dan Gohman
155eec7fa9 Fix a typo in a comment that Duncan noticed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94562 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 18:32:54 +00:00
Dan Gohman
93dacadb46 Rename ItCount to BECount, since it holds a backedge-taken count rather
than an iteration count.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94549 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 16:46:18 +00:00
Dan Gohman
52fddd3e36 Fix the the ceiling-division used in computing the MaxBECount so that it doesn't
have trouble with an intermediate add overflowing. Also, be more conservative
about the case where the induction variable in an SLT loop exit can step past
the RHS of the SLT and overflow in a single step.

Make getSignedRange more aggressive, to recover for some common cases which
the above fixes pessimized.

This addresses rdar://7561161.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94512 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 04:40:18 +00:00
Dan Gohman
a10756ee65 Re-implement the main strength-reduction portion of LoopStrengthReduction.
This new version is much more aggressive about doing "full" reduction in
cases where it reduces register pressure, and also more aggressive about
rewriting induction variables to count down (or up) to zero when doing so
reduces register pressure.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94061 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 02:09:26 +00:00
Dan Gohman
6784753814 Add a comment and tidy up some whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93932 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 22:27:22 +00:00
Dan Gohman
1cd9275c8d Give ScalarEvolution access to the DominatorTree. It'll need this
to make more intellegent AddRec folding decisions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93930 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 22:21:27 +00:00
Dan Gohman
3073329c53 Use WriteAsOperand instead of getName() to print loop header names,
so that unnamed blocks are handled.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93059 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-09 18:17:45 +00:00