Commit Graph

206 Commits

Author SHA1 Message Date
Daniel Dunbar
394f0441e0 Change create*Pass factory functions to return Pass* instead of
LoopPass*.
 - Although less precise, this means they can be used in clients
   without RTTI (who would otherwise need to include LoopPass.h, which
   eventually includes things using dynamic_cast). This was the
   simplest solution that presented itself, but I am happy to use a
   better one if available.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58010 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-22 23:32:42 +00:00
Dan Gohman
586b7b7547 Call ScalarEvolution's deleteValueFromRecords before deleting an
instruction, not after. This fixes some uses of free'd memory.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56908 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-01 02:02:03 +00:00
Dan Gohman
ad7321f58a Teach LSR to optimize away SMAX operations for tripcounts in common
cases.  See the comment above OptimizeSMax for the full story, and
the testcase for an example. This cancels out a pessimization
commonly attributed to indvars, and will allow us to lift some of
the artificial throttles in indvars, rather than add new ones.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56230 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-15 21:22:06 +00:00
Devang Patel
4b3f08bac7 fix overflow check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56011 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 20:54:34 +00:00
Devang Patel
245d0ab166 Remove unused counter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55924 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-08 17:14:54 +00:00
Devang Patel
175f9d94db Remove OptimizeIVType()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55913 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-08 16:13:27 +00:00
Dan Gohman
ae73dc1448 Tidy up several unbeseeming casts from pointer to intptr_t.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55779 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-04 17:05:41 +00:00
Devang Patel
e925ccc553 Add additional check to ensure that iv is canonicalized.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55682 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-03 00:29:13 +00:00
Devang Patel
a9348dc7ac Check iteration count.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55680 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-03 00:10:56 +00:00
Devang Patel
c72139134c While removing PHI, use basicblock to identify incoming value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55678 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-03 00:02:42 +00:00
Devang Patel
108f92e376 If all IV uses are extending integer IV then change the type of IV itself, if possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55674 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 22:18:08 +00:00
Devang Patel
18bb2788a0 Do not apply the transformation if the target does not support DestTy natively.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55433 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-27 20:55:23 +00:00
Devang Patel
541532724e Fix typos and whitespaces. Other cosmetic changes based on feedback.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55424 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-27 17:50:18 +00:00
Devang Patel
a0b3909d43 If IV is used in a int-to-float cast inside the loop then try to eliminate the cast operation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55374 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-26 17:57:54 +00:00
Evan Cheng
ee2aa85f44 Revert 54821. It's miscompiling 252.eon and 447.dealII
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54878 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 08:07:31 +00:00
Devang Patel
35115f92e4 Reapply 54786. Add overflow and number of mantissa bits checks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54821 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-15 21:21:34 +00:00
Evan Cheng
21066541ae Revert 54786. It's not checking for overflows, etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54813 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-15 08:12:11 +00:00
Devang Patel
79ceb4463e If IV is used in a int-to-float cast inside the loop then try to eliminate the cast opeation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54786 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-14 20:58:31 +00:00
Devang Patel
c677de2713 Rename. s/FindIVForUser/FindIVUserForCond/g
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54754 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-13 20:31:11 +00:00
Devang Patel
d16aba22c9 Check sign to detect overflow before changing compare stride.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54710 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-13 02:05:14 +00:00
Evan Cheng
f5e25f32c7 Fix PR2355: bug in ChangeCompareStride. When the loop termination compare is the only use of its iv stride, the stride can be eliminated by moving it to another stride. If the scale is negative, swap the predicate instead of using a inverse predicate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54415 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-06 18:04:43 +00:00
Dan Gohman
7375fbcbf2 Fix a bug in LSR's dead-PHI cleanup. If a PHI has a def-use chain that
leads into a cycle involving a different PHI, LSR got stuck running
around that cycle looking for the original PHI. To avoid this, keep
track of visited PHIs and stop searching if we see one more than once.
This fixes PR2570.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53879 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-21 21:45:02 +00:00
Dan Gohman
3fea643fb4 Fix uninitialized use of the Changed variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53564 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14 17:55:01 +00:00
Evan Cheng
1ce75dcbbc Fix two serious LSR bugs.
1. LSR runOnLoop is always returning false regardless if any transformation is made.
2. AddUsersIfInteresting can create new instructions that are added to DeadInsts. But there is a later early exit which prevents them from being freed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53193 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-07 19:51:32 +00:00
Dan Gohman
73b43b9b54 Fix spelling and grammar in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52648 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-23 22:11:52 +00:00
Dan Gohman
cbfe5bbe88 Improve LSR's dead-phi detection to handle use-def cycles
with more than two nodes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52617 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-22 20:44:02 +00:00
Dan Gohman
cfeb6a4506 Move LSR's private isZero function to a public SCEV member
function, and make use of it in several places.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52463 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 16:23:07 +00:00
Dan Gohman
9b93dd1f1a Refine the change in r52258 for avoiding use-before-def conditions
when changing the stride of a comparison so that it's slightly
more precise, by having it scan the instruction list to determine
if there is a use of the condition after the point where the
condition will be inserted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52371 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-16 22:34:15 +00:00
Evan Cheng
72b7b098c7 Switch over to SetVector to ensure same order of iterations do not vary across runs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52361 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-16 21:08:17 +00:00
Evan Cheng
69d5053f9c Iterating over SmallPtrSet is not deterministic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52339 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-16 18:17:09 +00:00
Dan Gohman
e562b1725e Protect ChangeCompareStride from situations in which it is possible
for it to generate use-before-def IR, such as in this testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52258 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-13 21:43:41 +00:00
Gabor Greif
6725cb5f1c op_iterator-ify some loops, fix 80col violations
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52226 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-11 21:38:51 +00:00
Evan Cheng
3cc8f9bfef Remove x86.sse2.loadh.pd and x86.sse2.loadl.pd. These will be lowered into load and shuffle instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51521 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-24 00:07:06 +00:00
Dan Gohman
010ee2d955 When LSR is replacing an instruction, call
ScalarEvolution::deleteValueFromRecords on it before doing the
replaceAllUsesWith, because ScalarEvolution looks at the instruction's
users to find SCEV references to the instruction's SCEV object in its
internal maps.

Move all of LSR's loop-related state clearing after processing the loop
and before cleaning up dead PHI nodes. This eliminates all of LSR's SCEV
references just before the calls to ScalarEvolution::deleteValueFromRecords
so that when ScalarEvolution drops its own SCEV references, the reference
counts will reach zero and the SCEVs will be deleted immediately.

These changes fix some compiler aborts involving ScalarEvolution holding
onto and reusing SCEV objects for instructions that have been deleted.
No regression test unfortunately; because the symptoms were due to
dangling pointers, reduced testcases ended up being fairly arbitrary.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51359 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-21 00:54:12 +00:00
Dan Gohman
ca756ae886 Refine the fix in r51169 to only apply when the operand val being
replaced is a PHI. This prevents it from inserting uses before defs
in the case that it isn't a PHI and it depends on other instructions
later in the block. This fixes the 447.dealII regression on x86-64.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51292 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-20 03:01:48 +00:00
Dan Gohman
f20d70d57e Fix a bug in LoopStrengthReduce that caused it to emit IR with
use-before-def. The problem comes up in code with multiple PHIs where
one PHI is being rewritten in terms of the other, but the other needs
to be casted first. LLVM rules requre the cast instruction to be
inserted after any PHI instructions, but when instructions were
inserted to replace the second PHI value with a function of the first,
they were ended up going before the cast instruction. Avoid this
problem by remembering the location of the cast instruction, when one
is needed, and inserting the expansion of the new value after it.

This fixes a bug that surfaced in 255.vortex on x86-64 when
instcombine was removed from the middle of the loop optimization
passes. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51169 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-15 23:26:57 +00:00
Dan Gohman
844731a7f1 Clean up the use of static and anonymous namespaces. This turned up
several things that were neither in an anonymous namespace nor static
but not intended to be global.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51017 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-13 00:00:25 +00:00
Dan Gohman
4a9a3e5374 Minor whitespace and comment cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49671 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-14 18:26:16 +00:00
Gabor Greif
051a950000 API changes for class Use size reduction, wave 1.
Specifically, introduction of XXX::Create methods
for Users that have a potentially variable number of
Uses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49277 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-06 20:25:17 +00:00
Evan Cheng
55e641b766 Remove dead options.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48556 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-19 22:02:26 +00:00
Dan Gohman
3035959425 Use empty() instead of comparing size() with zero.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46514 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 13:02:09 +00:00
Chris Lattner
4ee451de36 Remove attribution from file headers, per discussion on llvmdev.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45418 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 20:36:04 +00:00
Evan Cheng
32e4c7c486 Clean up previous patch: PHI uses should not prevent iv reuse if all other uses are addresses. This trades a constant multiply for one fewer iv.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45251 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-20 02:20:53 +00:00
Evan Cheng
d6b62a5722 Allow iv reuse if the user is a PHI node which is in turn used as addresses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45230 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-19 23:33:23 +00:00
Dale Johannesen
b51b4b5fdf Remove indeterminism from a loop. We think this will
fix an occasional nonrepeatable bootstrap failure we've
been seeing on Darwin.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44202 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-17 02:48:01 +00:00
Evan Cheng
0e0014d049 At end of LSR, replace uses of now constant (as result of SplitCriticalEdge) PHI node with the constant value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43533 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-30 23:45:15 +00:00
Evan Cheng
8392772727 It's not safe to tell SplitCriticalEdge to merge identical edges. It may delete the phi instruction that's being processed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43524 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-30 22:27:26 +00:00
Evan Cheng
af62c09437 - Bug fixes.
- Allow icmp rewrite using an iv / stride of a smaller integer type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43480 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 22:07:18 +00:00
Dan Gohman
9330c3af45 Update a comment to reflect the current code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43463 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 19:32:39 +00:00
Dan Gohman
8480bc5b5b Remove an unused function argument.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43462 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 19:31:25 +00:00