Commit Graph

2136 Commits

Author SHA1 Message Date
Dan Gohman
7e5440404b Change the description string of the LoopInfo pass.
"Construction" makes it sound like a pass that might
modify the CFG to construct natural loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70580 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 21:58:05 +00:00
Dan Gohman
cf5ab82022 Actually insert inserted instructions into the InsertedValues map.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70557 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 17:13:31 +00:00
Dan Gohman
9032b78c98 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70554 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 17:02:22 +00:00
Dan Gohman
80dcdee0f4 Short-circuit inttoptr-ptrtoint constant expressions; these aren't
always folded by the regular constant folder because it doesn't have
TargetData information.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70553 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 17:00:00 +00:00
Dan Gohman
99243b3830 Fix an 80-column violation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70550 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 16:44:56 +00:00
Dan Gohman
10b9479f55 When creating cast scevs, canonicalize the destination type. This
avoids duplicate scevs that differ only in type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70549 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 16:44:18 +00:00
Torok Edwin
e3d12854b8 hasSCEV() was declared in ScalarEvolution.h, but never defined. This must have
gone lost during the pImpl conversion.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70536 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 08:33:47 +00:00
Dan Gohman
3d739fe375 Add some comments, and tidy up some whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70510 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 20:48:53 +00:00
Dan Gohman
a1af757e0a 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70509 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 20:47:05 +00:00
Dan Gohman
4acd12a0cb Don't try to mix integers and pointers in an icmp instruction
in getSCEVAtScope.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70495 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 16:40:30 +00:00
Dan Gohman
d9c1c85c2a Fix ScalarEvolution::print to print a value for any Instruction with
a SCEVable type, not just integer types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70463 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 01:30:18 +00:00
Dan Gohman
eb3948be16 Implement getSCEVAtScope for SCEV cast expressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70422 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-29 22:29:01 +00:00
Dan Gohman
ac70ceafbc 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70421 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-29 22:28:28 +00:00
Dan Gohman
36b8e53fe0 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70405 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-29 20:27:52 +00:00
Dale Johannesen
c9cf35055f Fix recent regression in gcc.dg/pr26719.c (6835035).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70386 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-29 16:38:47 +00:00
Dan Gohman
f0aa4850ce Update comments to reflect the current code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70357 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-29 01:54:20 +00:00
Dan Gohman
01ecca20bf 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70241 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 20:16:15 +00:00
Dan Gohman
d6c329532b Handle ands with ~0 correctly too. This fixes PR4052.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 01:41:10 +00:00
Dan Gohman
2c73d5fb9e Handle ands with 0 and shifts by 0 correctly. These aren't
common, but indvars shouldn't crash on them. This fixes PR4054.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70051 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 17:05:40 +00:00
Dan Gohman
752ec7da50 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69892 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23 15:16:49 +00:00
Nick Lewycky
5cd28fad15 Simplify trunc(extend(x)) in SCEVs, just for completeness. Also fix some odd
whitespace in the same file.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69870 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23 05:15:08 +00:00
Devang Patel
e2a17468d1 Fix cut-n-pasto.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69816 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22 18:51:05 +00:00
Dan Gohman
20900cae35 Simplify trivial cast-of-cast SCEVs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69809 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22 16:20:48 +00:00
Dan Gohman
aabb04f527 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69808 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22 16:11:16 +00:00
Dan Gohman
6cdc727f2d Use BasicBlock::iterator instead of Instruction* for insert points,
to better handle inserting instructions at the end of a block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69807 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22 16:05:50 +00:00
Dan Gohman
f8a8be86e3 De-pImpl-ify ScalarEvolution. The pImpl pattern doesn't provide much
practical benefit in the case of ScalarEvolution, and it's otherwise
a nuisance.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69749 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 23:15:49 +00:00
Dan Gohman
578ccf81e5 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69704 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 20:18:36 +00:00
Dan Gohman
4ee29af754 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69655 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 02:26:00 +00:00
Dan Gohman
59d0704c8f This FIXME is fixed, now that SCEV understands pointers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69651 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 01:41:18 +00:00
Dan Gohman
84923602fd Factor out a common base class from SCEVTruncateExpr, SCEVZeroExtendExpr,
and SCEVSignExtendExpr.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69649 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 01:25:57 +00:00
Dan Gohman
a682430653 Usage getAnalysisToUpdate for TargetData, per PR760.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69645 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 01:11:19 +00:00
Dan Gohman
af79fb5f47 Introduce encapsulation for ScalarEvolution's TargetData object, and refactor
the code to minimize dependencies on TargetData.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69644 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 01:07:12 +00:00
Dan Gohman
fb17fd2cdf Move some assertion checks so they can do more complete checking.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69643 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 00:55:22 +00:00
Dan Gohman
b7ef72963b Convert ScalarEvolution to use raw_ostream instead of OStream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69640 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 00:47:46 +00:00
Dan Gohman
f4ccfcb704 Add a ScalarEvolution::getCouldNotCompute() function, and use it
instead of allocating and leaking new SCEVCouldNotCompute objects.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69452 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 17:58:19 +00:00
Dan Gohman
b40c23672b More const qualifiers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69451 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 17:57:20 +00:00
Dan Gohman
890f92b744 Use more const qualifiers with SCEV interfaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69450 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 17:56:28 +00:00
Dan Gohman
4d177592f2 Handle a pointer type correctly in SCEVExpander::visitAddRecExpr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69310 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 21:34:54 +00:00
Dan Gohman
8170a6849e Fix a bug with inttoptr/ptrtoint casts where the pointer has a different
size from the integer, requiring zero extension or truncation. Don't
create ZExtInsts with pointer types. This fixes a regression in
consumer-jpeg.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69307 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 19:25:55 +00:00
Dan Gohman
6524d3ab0e Fix SCEVExpander::visitSMaxExpr and SCEVExpander::visitUMaxExpr to
not create ICmpInsts with operands of different types. This fixes
a regression in Applications/d/make_dparser.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69294 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 16:15:25 +00:00
Dan Gohman
f04fa483b8 Teach SCEVExpander::InsertCastOfTo to avoid creating inttoptr-of-ptrtoint
and ptrtoint-of-inttoptr expressions. This fixes a regression in 300.twolf.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69293 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 15:52:57 +00:00
Dan Gohman
2d1be87ee4 Expand GEPs in ScalarEvolution expressions. SCEV expressions can now
have pointer types, though in contrast to C pointer types, SCEV
addition is never implicitly scaled. This not only eliminates the
need for special code like IndVars' EliminatePointerRecurrence
and LSR's own GEP expansion code, it also does a better job because
it lets the normal optimizations handle pointer expressions just
like integer expressions.

Also, since LLVM IR GEPs can't directly index into multi-dimensional
VLAs, moving the GEP analysis out of client code and into the SCEV
framework makes it easier for clients to handle multi-dimensional
VLAs the same way as other arrays.

Some existing regression tests show improved optimization.
test/CodeGen/ARM/2007-03-13-InstrSched.ll in particular improved to
the point where if-conversion started kicking in; I turned it off
for this test to preserve the intent of the test.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69258 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 03:18:22 +00:00
Devang Patel
af5b6bb6a5 Add a method to check that the subprogram holds debug info for the given Function or not.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69113 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 00:06:07 +00:00
Chris Lattner
6f532a988e use higher level APIs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68351 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-03 00:02:39 +00:00
Devang Patel
6d9a2df4ec getEntryFor() may invalidate DenseMap iterator.
Walking an invalidated iterator is not a good idea.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68047 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-30 18:34:47 +00:00
Chris Lattner
6a0dcc1077 now that you can put a PointerIntPair in a SmallPtrSet, remove some
hackish workarounds from memdep


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67971 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-29 00:24:04 +00:00
Devang Patel
575ec806e0 Before deleting a basic block, give other loop passes a chance cleanup analysis values, related to the instructions in the basic block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67719 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-25 23:57:48 +00:00
Devang Patel
25cb0d75d0 Do not ignore DW_TAG_class_type!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67675 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-25 03:52:06 +00:00
Gabor Greif
f73e319751 simplify logic and get rid of the assumption that operand 0 is the callee
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67642 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-24 19:28:39 +00:00
Dan Gohman
2ba682c7e2 LoopVR is not CFGOnly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67524 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23 15:50:52 +00:00