History log of /external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
dce4a407a24b04eebc6a376f8e62b41aaa7b071f 29-May-2014 Stephen Hines <srhines@google.com> Update LLVM for 3.5 rebase (r209712).

Change-Id: I149556c940fb7dc92d075273c87ff584f400941f
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
36b56886974eae4f9c5ebc96befd3e7bfe5de338 24-Apr-2014 Stephen Hines <srhines@google.com> Update to LLVM 3.5a.

Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4d4bbaf997c16f9e79503bd640306d784efd090e 25-Oct-2013 Andrew Trick <atrick@apple.com> Fix SCEVExpander: don't try to expand quadratic recurrences outside a loop.

Partial fix for PR17459: wrong code at -O3 on x86_64-linux-gnu
(affecting trunk and 3.3)

When SCEV expands a recurrence outside of a loop it attempts to scale
by the stride of the recurrence. Chained recurrences don't work that
way. We could compute binomial coefficients, but would hve to
guarantee that the chained AddRec's are in a perfectly reduced form.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193438 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5a2fb058d3628063cacc3dda0cda331c8d4dab11 19-Jun-2013 Quentin Colombet <qcolombet@apple.com> LSR: Fix the parameters used to compute the scaling factor cost.

Prior to this change, the considered addressing modes may be invalid since the
maximum and minimum offsets were not taking into account.
This was causing an assertion failure.

The added test case exercices that behavior.

<rdar://problem/14199725> Assertion failed: (CurScaleCost >= 0 && "Legal
addressing mode has an illegal cost!")


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184341 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
515971fdd77b82fe3dabdbaf34524cafc3f08415 15-Jun-2013 Jakub Staszak <kubastaszak@gmail.com> Use 0 instead of NULL.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184044 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
06f5ebc5a1604b01689cf2d482dd05f956538af6 31-May-2013 Quentin Colombet <qcolombet@apple.com> Loop Strength Reduce: Scaling factor cost.

Account for the cost of scaling factor in Loop Strength Reduce when rating the
formulae. This uses a target hook.

The default implementation of the hook is: if the addressing mode is legal, the
scaling factor is free.

<rdar://problem/13806271>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183045 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5b00f4edcbebad3b5474e3052b6d30ceb5d68e88 31-May-2013 Quentin Colombet <qcolombet@apple.com> Modify how the formulae are rated in Loop Strength Reduce.
Namely, check if the target allows to fold more that one register in the
addressing mode and if yes, adjust the cost accordingly.

Prior to this commit, reg1 + scale * reg2 accesses were artificially preferred
to reg1 + reg2 accesses. Indeed, the cost model wrongly assumed that reg1 + reg2
needs a temporary register for the computation, whereas it was correctly
estimated for reg1 + scale * reg2.

<rdar://problem/13973908>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183021 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c6af2432c802d241c8fffbe0371c023e6c58844e 25-May-2013 Michael J. Spencer <bigcheesegs@gmail.com> Replace Count{Leading,Trailing}Zeros_{32,64} with count{Leading,Trailing}Zeros.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182680 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
65a47ff55465096b272086356fdc06e02c8559dc 24-Mar-2013 Jakub Staszak <kubastaszak@gmail.com> Use dyn_cast instead of isa && cast.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177836 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d37c8568e68d0ea3492503cd192783900e2d922a 19-Mar-2013 Andrew Trick <atrick@apple.com> Revert "Cleanup some SCEV logic a bit."

This reverts commit 82cd8f7382322bee7a71cdc31f7a923c44d37d32.

Just add a comment instead!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177377 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
82cd8f7382322bee7a71cdc31f7a923c44d37d32 19-Mar-2013 Andrew Trick <atrick@apple.com> Cleanup some SCEV logic a bit.

Make the code more obvious to scan-build and humans.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177375 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4b02729558b5bca2208fa9649964676e7d018c4f 19-Mar-2013 Andrew Trick <atrick@apple.com> Tighten up an internal LSR API that should check for NULL.

No test case, but should fix a scan_build warning.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177374 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
71d6a79ada4de2178fce9fae2aa5627f0c268f56 16-Feb-2013 Jakub Staszak <kubastaszak@gmail.com> Reduce indents in LSRInstance::NarrowSearchSpaceByCollapsingUnrolledCode method.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175364 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6050edfe3e66ac45dbfaee72422b332ecaabb2ae 09-Feb-2013 Andrew Trick <atrick@apple.com> LSR IVChain improvement.

Handle chains in which the same offset is used for both loads and
stores to the same array.

Fixes rdar://11410078.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174789 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4fa57932c7b13ec42c563e33a2e40fd04194b64e 09-Feb-2013 Jakub Staszak <kubastaszak@gmail.com> Remove #includes from the commonly used LoopInfo.h.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174786 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
83474ee594b5b14e9071564814a90571805cc433 01-Feb-2013 Preston Gurd <preston.gurd@intel.com> This patch aims to improve compile time performance by increasing
the SCEV vector size in LoopStrengthReduce. It is observed that
the BaseRegs vector size is 4 in most cases,
and elements are frequently copied when it is initialized as
SmallVector<const SCEV *, 2> BaseRegs.
Our benchmark results show that the compilation time performance
improved by ~0.5%.

Patch by Wan Xiaofei.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174219 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
eab0ba03cfa8056ee19fe37d2b9fb7793c570564 13-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Fix an editor goof in r171738 that Bill spotted. He may even have a test
case, but looking at the diff this was an obviously unintended change.

Thanks for the careful review Bill! =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172336 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a07dcb1498ab1b1048bd03c664f3b7eb1f64310d 07-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Remove LSR's use of the random AddrMode struct. These variables were
already in a class, just inline the four of them. I suspect that this
class could be simplified some to not always keep distinct variables for
these things, but it wasn't clear to me how given the usage so I opted
for a trivial and mechanical translation.

This removes one of the two remaining users of a header in include/llvm
which does nothing more than define a 4 member struct.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171738 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e4ba75f43e2ab1480d119d2d4eb878256274e0fb 07-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Switch the SCEV expander and LoopStrengthReduce to use
TargetTransformInfo rather than TargetLowering, removing one of the
primary instances of the layering violation of Transforms depending
directly on Target.

This is a really big deal because LSR used to be a "special" pass that
could only be tested fully using llc and by looking at the full output
of it. It also couldn't run with any other loop passes because it had to
be created by the backend. No longer is this true. LSR is now just
a normal pass and we should probably lift the creation of LSR out of
lib/CodeGen/Passes.cpp and into the PassManagerBuilder. =] I've not done
this, or updated all of the tests to use opt and a triple, because
I suspect someone more familiar with LSR would do a better job. This
change should be essentially without functional impact for normal
compilations, and only change behvaior of targetless compilations.

The conversion required changing all of the LSR code to refer to the TTI
interfaces, which fortunately are very similar to TargetLowering's
interfaces. However, it also allowed us to *always* expect to have some
implementation around. I've pushed that simplification through the pass,
and leveraged it to simplify code somewhat. It required some test
updates for one of two things: either we used to skip some checks
altogether but now we get the default "no" answer for them, or we used
to have no information about the target and now we do have some.

I've also started the process of removing AddrMode, as the TTI interface
doesn't use it any longer. In some cases this simplifies code, and in
others it adds some complexity, but I think it's not a bad tradeoff even
there. Subsequent patches will try to clean this up even further and use
other (more appropriate) abstractions.

Yet again, almost all of the formatting changes brought to you by
clang-format. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171735 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c6b4936a59234704b788532de36d860f14b45e82 06-Jan-2013 Andrew Trick <atrick@apple.com> Fix a crash in LSR replaceCongruentIVs.

Indirect branch in the preheader crashes replaceCongruentIVs.
Fixes rdar://12910141.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171653 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0b8c9a80f20772c3793201ab5b251d3520b9cea3 02-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Move all of the header files which are involved in modelling the LLVM IR
into their new header subdirectory: include/llvm/IR. This matches the
directory structure of lib, and begins to correct a long standing point
of file layout clutter in LLVM.

There are still more header files to move here, but I wanted to handle
them in separate commits to make tracking what files make sense at each
layer easier.

The only really questionable files here are the target intrinsic
tablegen files. But that's a battle I'd rather not fight today.

I've updated both CMake and Makefile build systems (I think, and my
tests think, but I may have missed something).

I've also re-sorted the includes throughout the project. I'll be
committing updates to Clang, DragonEgg, and Polly momentarily.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171366 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d04a8d4b33ff316ca4cf961e06c9e312eff8e64f 03-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Use the new script to sort the includes of every file under lib.

Sooooo many of these had incorrect or strange main module includes.
I have manually inspected all of these, and fixed the main module
include to be the nearest plausible thing I could find. If you own or
care about any of these source files, I encourage you to take some time
and check that these edits were sensible. I can't have broken anything
(I strictly added headers, and reordered them, never removed), but they
may not be the headers you'd really like to identify as containing the
API being implemented.

Many forward declarations and missing includes were added to a header
files to allow them to parse cleanly when included first. The main
module rule does in fact have its merits. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a04a4a79ea365d1ba96ed4b5861e879b267162e2 19-Oct-2012 Nadav Rotem <nrotem@apple.com> revert r166264 because the LTO build is still failing

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166340 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
725f1d12801109a3b1d081a6e1c9e44426b2cf34 19-Oct-2012 Nadav Rotem <nrotem@apple.com> recommit the patch that makes LSR and LowerInvoke use the TargetTransform interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166264 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3b9a911efcf280950f878a050728450423875639 18-Oct-2012 Bob Wilson <bob.wilson@apple.com> Temporarily revert the TargetTransform changes.

The TargetTransform changes are breaking LTO bootstraps of clang. I am
working with Nadav to figure out the problem, but I am reverting it for now
to get our buildbots working.

This reverts svn commits: 165665 165669 165670 165786 165787 165997
and I have also reverted clang svn 165741

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166168 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e3d0e86919730784faaddcb5d9b0257c39b0804b 11-Oct-2012 Nadav Rotem <nrotem@apple.com> Add a new interface to allow IR-level passes to access codegen-specific information.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165665 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ad6aedc7d980d407da4452ff3ed4592d3df1a3f7 09-Oct-2012 Nadav Rotem <nrotem@apple.com> Refactor the AddrMode class out of TLI to its own header file.
This class is used by LSR and a number of places in the codegen.
This is the first step in de-coupling LSR from TLI, and creating
a new interface in between them.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165455 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f08c115e6c4b24b975ce376574f7daf6d5a92462 18-Sep-2012 Andrew Trick <atrick@apple.com> LSR critical edge splitting fix for PR13756.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164147 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
286c4dc355b8be6806081b23c3097485821c7642 12-Sep-2012 Manman Ren <mren@apple.com> Release build: guard dump functions with
"#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)"

No functional change. Update r163344.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163679 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
cc77eece74c8db09acc2af425e7e6c88a5bb30d1 06-Sep-2012 Manman Ren <mren@apple.com> Release build: guard dump functions with "ifndef NDEBUG"

No functional change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163344 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
875cc5d629697c16fd24662f7cce21766c3d2e4e 21-Aug-2012 Richard Smith <richard-llvm@metafoo.co.uk> Don't bind a reference to a dereferenced null pointer (for return value of WeakVH::operator*).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162309 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
06a27cc1aae20e3a2c985dd8dadab3b4ef5d032a 17-Jul-2012 Andrew Trick <atrick@apple.com> Reapply r160340. LSR: Limit CollectSubexprs.

Speculatively fix crashes by code inspection. Can't reproduce them yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160344 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
81ba5060ea06563b3052840a28cd08cc2d54a99f 17-Jul-2012 Andrew Trick <atrick@apple.com> Revert "LSR: try not to blow up solving combinatorial problems brute force."

Some units tests crashed on a different platform.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160341 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6a51a7aea5d0ae8a0b4ec2162b57c50c68b4c3a9 17-Jul-2012 Andrew Trick <atrick@apple.com> LSR: try not to blow up solving combinatorial problems brute force.

This places limits on CollectSubexprs to constrains the number of
reassociation possibilities. It limits the recursion depth and skips
over chains of nested recurrences outside the current loop.

Fixes PR13361. Although underlying SCEV behavior is still potentially bad.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160340 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e08c32249fca32cd7b122024a4ca252fcb235694 14-Jul-2012 Andrew Trick <atrick@apple.com> LSR Fix: check SCEV expression safety before expansion.

All SCEV expressions used by LSR formulae must be safe to
expand. i.e. they may not contain UDiv unless we can prove nonzero
denominator.

Fixes PR11356: LSR hoists UDiv.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160205 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b6b5b7b69113c5c3e49caf78adb1c2c4cf216db3 15-Jun-2012 Andrew Trick <atrick@apple.com> LSR: fix expansion of scaled reg in non-address type formulae.

For non-address users, Base and Scaled registers are not specially
associated to fit an address mode, so SCEVExpander should apply normal
expansion rules. Otherwise we may sink computation into inner loops
that have already been optimized.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158537 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
546f2101152f75c8d84115f6a6b2f3c16389b1ac 15-Jun-2012 Andrew Trick <atrick@apple.com> LSR fix: "Special" users are just like "Basic" users but allow -1 scale.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158536 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d9b0b025612992a0b724eeca8bdf10b1d7a5c355 02-Jun-2012 Benjamin Kramer <benny.kra@googlemail.com> Fix typos found by http://github.com/lyda/misspell-check

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157885 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9719cf329bc398191c65cd1c8cb1161d11c5e947 30-Apr-2012 Rafael Espindola <rafael.espindola@gmail.com> Make sure HoistInsertPosition finds a position that is dominated by all
inputs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155809 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f9f1c7aa89c87a9c8d6b8b317957b24e44f66570 27-Apr-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Break up getProfitableChainIncrement().

The required checks are moved to ChainInstruction() itself and the
policy decisions are moved to IVChain::isProfitableInc().

Also cache the ExprBase in IVChain to avoid frequent recomputations.

No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155676 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
70a1860a463ce5278486f70d3808efdfc4c2e191 27-Apr-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Turn IVChain into a struct.

No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155675 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
165324cd7da5d4c534c52f7db51e6ef0c185cf5b 25-Apr-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Print IV chain numbers while collecting them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155567 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b5122635966a980a850c028895e275a43e0f946d 18-Apr-2012 Andrew Trick <atrick@apple.com> loop-reduce: Add an early bailout to catch extremely large loops.

This introduces a threshold of 200 IV Users, which is very
conservative but should be sufficient to avoid serious compile time
sink or stack overflow. The llvm test-suite with LTO never exceeds 190
users per loop.

The bug doesn't relate to a specific type of loop. Checking in an
arbitrary giant loop as a unit test would be silly.

Fixes rdar://11262507.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154983 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9243c4f7c54b8d0be22a4c9d411b15f462039d06 05-Apr-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Pass the right sign to TLI->isLegalICmpImmediate.

LSR can fold three addressing modes into its ICmpZero node:

ICmpZero BaseReg + Offset => ICmp BaseReg, -Offset
ICmpZero -1*ScaleReg + Offset => ICmp ScaleReg, Offset
ICmpZero BaseReg + -1*ScaleReg => ICmp BaseReg, ScaleReg

The first two cases are only used if TLI->isLegalICmpImmediate() likes
the offset.

Make sure the right Offset sign is passed to this method in the second
case. The ARM version is not symmetric.

<rdar://problem/11184260>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154079 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
05fecbe42e835b30274a7b38af27687a8abbd114 26-Mar-2012 Andrew Trick <atrick@apple.com> LSR ivchain bug fix: corner case with ConstantExpr.

Fixes PR11950.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153463 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d4e46a6316c8e1dc4623ead64b4cdd3dfb103180 26-Mar-2012 Andrew Trick <atrick@apple.com> comment typo

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153462 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
81748bc32092c75c61bb7cb34bfb5a616924e535 26-Mar-2012 Andrew Trick <atrick@apple.com> LSR cleanup: potential bug caught by PVS-Studio.

Thanks Andrey.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153451 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d1944547b73ee7a4ed840a14d164929f1f7c7f12 22-Mar-2012 Andrew Trick <atrick@apple.com> Remove -enable-lsr-retry in time for 3.1.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153287 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
bd618f1b7ff73bde1e421eb6daf978e74984e180 22-Mar-2012 Andrew Trick <atrick@apple.com> Remove -enable-lsr-nested in time for 3.1.

Tests cases have been removed but attached to open PR12330.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153286 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
75ae20366fd1b480f4cc38400bb075c43c9f4f7f 16-Mar-2012 Andrew Trick <atrick@apple.com> LSR fix: Add isSimplifiedLoopNest to IVUsers analysis.

Only record IVUsers that are dominated by simplified loop
headers. Otherwise SCEVExpander will crash while looking for a
preheader.

I previously tried to work around this in LSR itself, but that was
insufficient. This way, LSR can continue to run if some uses are not
in simple loops, as long as we don't attempt to analyze those users.

Fixes <rdar://problem/11049788> Segmentation fault: 11 in LoopStrengthReduce

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152892 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4d6ccb5f68cd7c6418a209f1fa4dbade569e4493 20-Jan-2012 David Blaikie <dblaikie@gmail.com> More dead code removal (using -Wunreachable-code)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148578 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0041d4d447c26825e566ba38a4fe301471fda1eb 20-Jan-2012 Andrew Trick <atrick@apple.com> Handle a corner case with IV chain collection with bailout instead of assert.

Fixes PR11783: bad cast to AddRecExpr.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148572 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b5c26ef9da16052597d59a412eaae32098aa1be0 20-Jan-2012 Andrew Trick <atrick@apple.com> SCEVExpander fixes. Affects LSR and indvars.

LSR has gradually been improved to more aggressively reuse existing code, particularly existing phi cycles. This exposed problems with the SCEVExpander's sloppy treatment of its insertion point. I applied some rigor to the insertion point problem that will hopefully avoid an endless bug cycle in this area. Changes:

- Always used properlyDominates to check safe code hoisting.

- The insertion point provided to SCEV is now considered a lower bound. This is usually a block terminator or the use itself. Under no cirumstance may SCEVExpander insert below this point.

- LSR is reponsible for finding a "canonical" insertion point across expansion of different expressions.

- Robust logic to determine whether IV increments are in "expanded" form and/or can be safely hoisted above some insertion point.

Fixes PR11783: SCEVExpander assert.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148535 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0f080913d1ff80bb61476724304359e14822b193 17-Jan-2012 Andrew Trick <atrick@apple.com> LSR fix: broaden the check for loop preheaders.

It's becoming clear that LoopSimplify needs to unconditionally create loop preheaders. But that is a bigger fix. For now, continuing to hack LSR.
Fixes rdar://10701050 "Cannot split an edge from an IndirectBrInst" assert.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148288 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
64925c55c65f9345a69fb67db07aa62cfb723577 10-Jan-2012 Andrew Trick <atrick@apple.com> Enable LSR IV Chains with sufficient heuristics.

These heuristics are sufficient for enabling IV chains by
default. Performance analysis has been done for i386, x86_64, and
thumbv7. The optimization is rarely important, but can significantly
speed up certain cases by eliminating spill code within the
loop. Unrolled loops are prime candidates for IV chains. In many
cases, the final code could still be improved with more target
specific optimization following LSR. The goal of this feature is for
LSR to make the best choice of induction variables.

Instruction selection may not completely take advantage of this
feature yet. As a result, there could be cases of slight code size
increase.

Code size can be worse on x86 because it doesn't support postincrement
addressing. In fact, when chains are formed, you may see redundant
address plus stride addition in the addressing mode. GenerateIVChains
tries to compensate for the common cases.

On ARM, code size increase can be mitigated by using postincrement
addressing, but downstream codegen currently misses some opportunities.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147826 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
22d20c218aeb14af388bff2346d6d4cc131e8449 09-Jan-2012 Andrew Trick <atrick@apple.com> Adding IV chain generation to LSR.

After collecting chains, check if any should be materialized. If so,
hide the chained IV users from the LSR solver. LSR will only solve for
the head of the chain. GenerateIVChains will then materialize the
chained IV users by computing the IV relative to its previous value in
the chain.

In theory, chained IV users could be exposed to LSR's solver. This
would be considerably complicated to implement and I'm not aware of a
case where we need it. In practice it's more important to
intelligently prune the search space of nontrivial loops before
running the solver, otherwise the solver is often forced to prune the
most optimal solutions. Hiding the chained users does this well, so
that LSR is more likely to find the best IV for the chain as a whole.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147801 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6c7d0ae8dc8beb37efd6c0ff586035253856e07c 09-Jan-2012 Andrew Trick <atrick@apple.com> Adding collection of IV chains to LSR.

This collects a set of IV uses within the loop whose values can be
computed relative to each other in a sequence. Following checkins will
make use of this information.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147797 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
8bf295b1bf345dda7f3f5cd12b5c0dafea283e81 09-Jan-2012 Andrew Trick <atrick@apple.com> "Minor LSR debugging stuff"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147785 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
24f670f1bae0281b08276229041dfc952a810dbf 07-Jan-2012 Andrew Trick <atrick@apple.com> Enable redundant phi elimination after LSR.

This will be more important as we extend the LSR pass in ways that don't rely on the formula solver. In particular, we need it for constructing IV chains.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147724 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
acdb4aaf9b1f2edd96163c27bcc4e0557014f51e 07-Jan-2012 Andrew Trick <atrick@apple.com> LSR: Don't optimize loops if an outer loop has no preheader.

LoopSimplify may not run on some outer loops, e.g. because of indirect
branches. SCEVExpander simply cannot handle outer loops with no preheaders.
Fixes rdar://10655343 SCEVExpander segfault.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147718 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f231a6dc7f251859af61677991b9c70ade6e1bfa 07-Jan-2012 Andrew Trick <atrick@apple.com> LSR: run DeleteDeadPhis before replaceCongruentPhis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147711 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ee98aa87434d9d49a8e4dab41d873888ac9c4805 07-Jan-2012 Andrew Trick <atrick@apple.com> Extended replaceCongruentPhis to handle mixed phi types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147707 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d56ef8d709c3dd5735debc23e082722718a7d58a 13-Dec-2011 Andrew Trick <atrick@apple.com> Cleanup. Clarify LSRInstance public methods.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146459 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
fa1948a40f14d98c1a31a2ec19035a2d5254e854 10-Dec-2011 Andrew Trick <atrick@apple.com> LSR: ignore strides in outer loops.

Since we're not rewriting IVs in other loops, there's not much reason
to consider their stride when generating formulae.
This should reduce the number of useless formulas considered by LSR.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146302 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
8a5d792944582de8e63e96440dbd2cde754351ad 06-Dec-2011 Andrew Trick <atrick@apple.com> LSR: prune undesirable formulae early.

It's always good to prune early, but formulae that are unsatisfactory
in their own right need to be removed before running any other pruning
heuristics. We easily avoid generating such formulae, but we need them
as an intermediate basis for forming other good formulae.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145906 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0861f5793a1834f02b522fb86fb037cd592c134f 27-Nov-2011 Benjamin Kramer <benny.kra@googlemail.com> Move code into anonymous namespaces.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145154 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
de631128d69dc95f9f6b0c225a52fc08593be59f 15-Nov-2011 Nadav Rotem <nadav.rotem@intel.com> Fix MSVC warnings by adding a cast.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144721 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
dae36ba802f12966e4fc44d99097a55ff0b7d87b 14-Oct-2011 Eli Friedman <eli.friedman@gmail.com> Avoid undefined behavior in negation in LSR. Patch by Ahmed Charles.

Someone more familiar with LSR should double-check that the extra cast is actually doing the right thing in the overflow cases; I'm not completely confident that's that case.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141916 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a02bfced06b4cc700e50bc497cc42667653f091a 11-Oct-2011 Andrew Trick <atrick@apple.com> Add experimental -enable-lsr-phielim option.

I'm not sure we will need it in the long run, but the option is
currently useful for checking if the output of LSR is "clean".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141634 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c5701910604cdf65811fabd31d41e38f1d1d4eb1 08-Oct-2011 Andrew Trick <atrick@apple.com> LSR should only reuse phis that match its formula.

Fixes rdar://problem/5064068


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141442 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f143b79b78d1d244809fa59320f2af2edf4e1a86 04-Oct-2011 Andrew Trick <atrick@apple.com> LSR should avoid redundant edge splitting.

This handles the case in which LSR rewrites an IV user that is a phi and
splits critical edges originating from a switch.
Fixes <rdar://problem/6453893> LSR is not splitting edges "nicely"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141059 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5219f86a0bab11dd6895a31653e371e9871a6734 29-Sep-2011 Andrew Trick <atrick@apple.com> typo + pasto


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140769 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0c01bc385a4c01bee012bda504c8ce0c3d402f2c 29-Sep-2011 Andrew Trick <atrick@apple.com> LSR: rewrite inner loops only.

Rewriting the entire loop nest now requires -enable-lsr-nested.
See PR11035 for some performance data.
A few unit tests specifically test nested LSR, and are now under a flag.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140762 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
80ef1b287fa1b62ad3de8a7c3658ff37b5acca8e 27-Sep-2011 Andrew Trick <atrick@apple.com> Disable LSR retry by default.

Disabling aggressive LSR saves compilation time, and with the new
indvars behavior usually improves performance.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140590 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
25b689e067697d3b49ae123120703fada030350f 27-Sep-2011 Andrew Trick <atrick@apple.com> LSR, one of the new Cost::isLoser() checks did not get merged in the previous checkin.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140583 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7d11bd850f97f499117704cd3e03d6a6cc1adcb3 27-Sep-2011 Andrew Trick <atrick@apple.com> LSR cost metric minor fix and verification.

The minor bug heuristic was noticed by inspection. I added the
isLoser/isValid helpers because they will become more
important with subsequent checkins.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140580 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b5b7c96ce4e120297304e5cef5b4b0af8e9e8691 24-Sep-2011 Andrew Trick <atrick@apple.com> LSR minor bug fix in RateRegister.

No test case. Noticed by inspection and I doubt it ever affects the
outcome of the overall heuristic, let alone final codegen.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140431 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
8b6af8a2a9a36bc9324c60d80cea021abf4d42d8 25-Aug-2011 Bill Wendling <isanbard@gmail.com> LSR wants to split the landing pad's critical edge. Let it do it, but use the
proper function to do it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138550 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
89d4411cef736898047aa7e3bc159da39cacf8e6 25-Aug-2011 Bill Wendling <isanbard@gmail.com> When inserting new instructions, use getFirstInsertionPt instead of
getFirstNonPHI so that it will skip over the landingpad instructions as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138537 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a4c86ab073d4b7a36477fc7c54c9d52499f04586 24-Aug-2011 Bill Wendling <isanbard@gmail.com> Skip the landingpad instruction when determining the insertion point.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138481 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c205a094bd5019773c98adcfbdc21c07c9da1888 21-Jul-2011 Andrew Trick <atrick@apple.com> LSR, correct fix for rdar://9786536. Silly casting bug.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135654 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c2c988e5e0b15408f790c96fd7ad2d86a6a93a08 21-Jul-2011 Andrew Trick <atrick@apple.com> LSR must sometimes sign-extend before generating double constants.

rdar://9786536


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135650 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
37eb38d3f8531115f17f4e829013ccb513952bad 21-Jul-2011 Andrew Trick <atrick@apple.com> LSR crashes on an empty IVUsers list.

rdar://9786536


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135644 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
db125cfaf57cc83e7dd7453de2d509bc8efd0e5e 18-Jul-2011 Chris Lattner <sabre@nondot.org> land David Blaikie's patch to de-constify Type, with a few tweaks.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135375 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c73b24db5f6226ed44ebc44ce1c25bb357206623 15-Jul-2011 Chris Lattner <sabre@nondot.org> start using the new helper methods a bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135251 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5e7645be4c9dd2193add44d30b5fef8036d7a3ce 28-Jun-2011 Andrew Trick <atrick@apple.com> SCEVExpander: give new insts a name that identifies the reponsible pass.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133992 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4417e537b65c14b378aeca75b2773582dd102f63 21-Jun-2011 Andrew Trick <atrick@apple.com> IVUsers no longer needs to record the phis.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133518 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1b58d4536a561f28bf935dcb29b483c52a6bf4c6 23-May-2011 Dan Gohman <gohman@apple.com> When checking for signed multiplication overflow, watch out for INT_MIN and -1.
This fixes PR9845.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131919 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f85092c25525f75eef6982ffa40c9b48b87da987 20-May-2011 Andrew Trick <atrick@apple.com> indvars: Prototyping Sign/ZeroExtend elimination without canonical IVs.

No functionality enabled by default. Use -disable-iv-rewrite.
Extended IVUsers to keep track of the phi that represents the users' IV.
Added the WidenIV transform to replace a narrow IV with a wide IV
by doing a one-for-one replacement of IV users instead of expanding the
SCEV expressions. [sz]exts are removed and truncs are inserted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131744 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
673968ae78f26bd78337d8bbb212fd280839fc12 18-May-2011 Dan Gohman <gohman@apple.com> When forming an ICmpZero LSRUse, normalize the non-IV operand
of the comparison, so that the resulting expression is fully
normalized. This fixes PR9939.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131576 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
cca82149adef8306a295abdc963213ae3b11bbb6 03-May-2011 Dan Gohman <gohman@apple.com> Add an unfolded offset field to LSR's Formula record. This is used to
model constants which can be added to base registers via add-immediate
instructions which don't require an additional register to materialize
the immediate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130743 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7a2bdde0a0eebcd2125055e0eacaca040f0b766c 15-Apr-2011 Chris Lattner <sabre@nondot.org> Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129558 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f93f7b2446bec3febc30b7136e18704664bd98cc 13-Apr-2011 Bill Wendling <isanbard@gmail.com> Reapply r129401 with patch for clang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129419 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f9b2dc66c87256b55f9bdfe037d1fa6f705200e8 13-Apr-2011 Bill Wendling <isanbard@gmail.com> Revert r129401 for now. Clang is using the old way of doing things.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129403 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d5f323d70bd2d9bc8a63a68bfe439a69e0104bbf 13-Apr-2011 Bill Wendling <isanbard@gmail.com> Remove the unaligned load intrinsics in favor of using native unaligned loads.

Now that we have a first-class way to represent unaligned loads, the unaligned
load intrinsics are superfluous.

First part of <rdar://problem/8460511>.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129401 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3ecfc861b4365f341c5c969b40e1afccde676e6f 30-Mar-2011 Jay Foad <jay.foad@gmail.com> Remove PHINode::reserveOperandSpace(). Instead, add a parameter to
PHINode::Create() giving the (known or expected) number of operands.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128537 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d8b4fb4aab4d6fedb2b14bed1b846451b17bde7c 30-Mar-2011 Jay Foad <jay.foad@gmail.com> (Almost) always call reserveOperandSpace() on newly created PHINodes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128535 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3228cc259b5ca00e46af36da369a451f5736cbf4 14-Mar-2011 Andrew Trick <atrick@apple.com> Added SCEV::NoWrapFlags to manage unsigned, signed, and self wrap
properties.
Added the self-wrap flag for SCEV::AddRecExpr.
A slew of temporary FIXMEs indicate the intention of the no-self-wrap flag
without changing behavior in this revision.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127590 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2c2b933037ecd5a0ebcfa3077606892802c04a29 11-Feb-2011 Cameron Zwarich <zwarich@apple.com> If we can't avoid running loop-simplify twice for now, at least avoid running
iv-users twice.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125318 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6793c49bb4b7d20532e530404740422036d84788 10-Feb-2011 Eric Christopher <echristo@apple.com> Revert this in an attempt to bring the builders back.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125257 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
de0c42a73ac0787921d0020238af309f4b91451f 10-Feb-2011 Cameron Zwarich <zwarich@apple.com> Turn this pass ordering:

Natural Loop Information
Loop Pass Manager
Canonicalize natural loops
Scalar Evolution Analysis
Loop Pass Manager
Induction Variable Users
Canonicalize natural loops
Induction Variable Users
Loop Strength Reduction

into this:

Scalar Evolution Analysis
Loop Pass Manager
Canonicalize natural loops
Induction Variable Users
Loop Strength Reduction

This fixes <rdar://problem/8869639>. I also filed PR9184 on doing this sort of
thing automatically, but it seems easier to just change the ordering of the
passes if this is the only case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125254 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3ef9838f89617fc471b6b84a64c7af824a070e50 08-Feb-2011 Dan Gohman <gohman@apple.com> Don't split any loop backedges, including backedges of loops other than
the active loop. This is generally desirable, and it avoids trouble
in situations such as the testcase in PR9123, though the failure
mode depends on use-list order, so it is infeasible to test.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125065 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
301278719b67dcdd1159d9f91b4db5ef57f025c6 18-Jan-2011 Cameron Zwarich <zwarich@apple.com> Remove code for updating dominance frontiers and some outdated references to
dominance and post-dominance frontiers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123725 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9fc5cdf77c812aaa80419036de27576d45894d0d 02-Jan-2011 Chris Lattner <sabre@nondot.org> split dom frontier handling stuff out to its own DominanceFrontier header,
so that Dominators.h is *just* domtree. Also prune #includes a bit.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122714 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
dc0e8fb9f9512622f55f73e1a434caa5c0915694 17-Nov-2010 Dan Gohman <gohman@apple.com> Move SCEV::dominates and properlyDominates to ScalarEvolution.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119570 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
17ead4ff4baceb2c5503f233d0288d363ae44165 17-Nov-2010 Dan Gohman <gohman@apple.com> Move SCEV::isLoopInvariant and hasComputableLoopEvolution to be member
functions of ScalarEvolution, in preparation for memoization and
other optimizations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119562 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
205942a4a55d568e93480fc22d25cc7dac525fb7 19-Oct-2010 Owen Anderson <resistor@mac.com> Passes do not need to recursively initialize passes that they preserve, if
they do not also require them. This allows us to reduce inter-pass linkage
dependencies.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116854 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
081c34b725980f995be9080eaec24cd3dfaaf065 19-Oct-2010 Owen Anderson <resistor@mac.com> Get rid of static constructors for pass registration. Instead, every pass exposes an initializeMyPassFunction(), which
must be called in the pass's constructor. This function uses static dependency declarations to recursively initialize
the pass's dependencies.

Clients that only create passes through the createFooPass() APIs will require no changes. Clients that want to use the
CommandLine options for passes will need to manually call the appropriate initialization functions in PassInitialization.h
before parsing commandline arguments.

I have tested this with all standard configurations of clang and llvm-gcc on Darwin. It is possible that there are problems
with the static dependencies that will only be visible with non-standard options. If you encounter any crash in pass
registration/creation, please send the testcase to me directly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116820 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2ab36d350293c77fc8941ce1023e4899df7e3a82 12-Oct-2010 Owen Anderson <resistor@mac.com> Begin adding static dependence information to passes, which will allow us to
perform initialization without static constructors AND without explicit initialization
by the client. For the moment, passes are required to initialize both their
(potential) dependencies and any passes they preserve. I hope to be able to relax
the latter requirement in the future.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116334 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c2921ea840a0c87f6c4f065bc775a9060e2aa626 08-Oct-2010 Dan Gohman <gohman@apple.com> Filter out illegal formulae after updating offsets, not before, so that
formulae which become illegal as a result of the offset updating don't
escape.

This is for rdar://8529692. No testcase yet, because the given cases
hit use-list ordering differences.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116093 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
fc7744b12d7de51f0cda300d939820d06bc8d087 08-Oct-2010 Dan Gohman <gohman@apple.com> Delete the FormulaSorter class and inline its one method into its
one user. This code will be restructured soon and FormulaSorter
is getting in the way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116012 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f63d70f218807d7522e8bbe2d9e887ff3ea87b24 08-Oct-2010 Dan Gohman <gohman@apple.com> Fix a spello.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116011 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
23c3fde39aa35334e74c26273a8973a872871e34 08-Oct-2010 Dan Gohman <gohman@apple.com> Charge a formula for explicit multiplies on scaled registers too,
not just base registers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116010 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0d6715a413a23c021d1042719888966bb8d11872 08-Oct-2010 Dan Gohman <gohman@apple.com> Use size_t for consistency.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116009 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
dd3db0e0c33958328cc709f01aba45c8d9e57f1f 08-Oct-2010 Dan Gohman <gohman@apple.com> When merging one use into another, transfer the offsets from
the old use to the new one.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116008 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c6897706b7c3796ac24535c9ea1449c0411f8c7a 08-Oct-2010 Dan Gohman <gohman@apple.com> Fix LSR to keep the RegUseTracker up to date when combining users.
This doesn't usually matter, because the other heuristics usually
succeed regardless, but it's good to keep the register use
bookkeeping consistent.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116005 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ce665bd2e2b581ab0858d1afe359192bac96b868 08-Oct-2010 Owen Anderson <resistor@mac.com> Now with fewer extraneous semicolons!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115996 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
51138b3070ddbbaf74ed661f820c3229d3c11f36 27-Sep-2010 Dan Gohman <gohman@apple.com> Delete an unused function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114841 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f097b59e0e2231d431a6c660c65fa5cae22d9a44 18-Sep-2010 Gabor Greif <ggreif@gmail.com> do not rely on the implicit-dereference semantics of dyn_cast_or_null

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114278 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
191bd64a39490fa75d35b9aaecdd57b00c7a8b5f 01-Sep-2010 Dan Gohman <gohman@apple.com> Revert 112442 and 112440 until the compile time problems introduced
by 112440 are resolved.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112692 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4f7e18dee35c55e4e719f5fb73726ab035a7e5db 29-Aug-2010 Dan Gohman <gohman@apple.com> Optionally rerun dedicated-register filtering after applying
other filtering techniques, as those may allow it to filter
out more obviously unprofitable candidates.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112441 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
25608f7f4b352aa3ff6004aadde11dc86ff85eda 29-Aug-2010 Dan Gohman <gohman@apple.com> Fix several areas in LSR to do a better job keeping the main
LSRInstance data structures up to date. This fixes some
pessimizations caused by stale data which will be exposed
in an upcoming change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112440 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4aa5c2e90f70c7032a075bee06b8a08e731d99ec 29-Aug-2010 Dan Gohman <gohman@apple.com> Refactor the three main groups of code out of
NarrowSearchSpaceUsingHeuristics into separate functions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112439 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e39a47c5b3bdab84f98046fc133a89170a9f0ee9 29-Aug-2010 Dan Gohman <gohman@apple.com> Delete a bogus check.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112438 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6a832715325f740a0e78acd194abad9104389075 29-Aug-2010 Dan Gohman <gohman@apple.com> Add some comments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112437 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3902f9fca8dd69ca3c5fce564deff817d7db3a8b 29-Aug-2010 Dan Gohman <gohman@apple.com> Move this debug output into GenerateAllReuseFormula, to declutter
the high-level logic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112436 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a7d0d64b7ae675908fefa1bc927ecc6b9024f48c 29-Aug-2010 Dan Gohman <gohman@apple.com> Delete an unused declaration.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112435 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
46fd7a6ef8766d5d1b5816e9f2ceff51d5ceb006 29-Aug-2010 Dan Gohman <gohman@apple.com> Do one lookup instead of two.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112434 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
694a15eabed6af4ba6da14ab4b0b25dceb980d55 19-Aug-2010 Dan Gohman <gohman@apple.com> Process the step before the start, because it's usually the simpler
of the two.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111495 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3e22b7c91698f55b9053e88a168bd9e2eed71c9b 16-Aug-2010 Dan Gohman <gohman@apple.com> Instead of having CollectSubexpr's categorize operands as interesting or
uninteresting, just put all the operands on one list and make
GenerateReassociations make the decision about what's interesting.
This is simpler, and it avoids an extra ScalarEvolution::getAddExpr call.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111133 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4065f609128ea4cdfa575f48b816d1cc64e710e0 16-Aug-2010 Dan Gohman <gohman@apple.com> Put add operands in ScalarEvolution-canonical order, when convenient.
This isn't necessary, because ScalarEvolution sorts them anyway,
but it's tidier this way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111132 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e62d58884ad83d0351b9511d58eed4b21ff6e0b1 13-Aug-2010 Dan Gohman <gohman@apple.com> Fix LSR's ExtractImmediate and ExtractSymbol to avoid calling
ScalarEvolution::getAddExpr, which can be pretty expensive, when nothing
has changed, which is pretty common.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111042 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
90c579de5a383cee278acc3f7e7b9d0a656e6a35 06-Aug-2010 Owen Anderson <resistor@mac.com> Reapply r110396, with fixes to appease the Linux buildbot gods.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110460 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1f74590e9d1b9cf0f1f81a156efea73f76546e05 06-Aug-2010 Owen Anderson <resistor@mac.com> Revert r110396 to fix buildbots.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110410 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9ccaf53ada99c63737547c0235baeb8454b04e80 06-Aug-2010 Owen Anderson <resistor@mac.com> Don't use PassInfo* as a type identifier for passes. Instead, use the address of the static
ID member as the sole unique type identifier. Clean up APIs related to this change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110396 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4eaee28e347f33b3e23d2fb7275fc5222d5482fd 04-Aug-2010 Dan Gohman <gohman@apple.com> Fix whitespace.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110223 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ee56c42168f6c4271593f6018c4409b6a5910302 02-Aug-2010 Oscar Fuentes <ofv@wanadoo.es> Prefix `next' iterator operation with `llvm::'.

Fixes potential ambiguity problems on VS 2010.

Patch by nobled!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110029 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d13db2c59cc94162d6cf0a04187d408bfef6d4a7 22-Jul-2010 Owen Anderson <resistor@mac.com> Fix batch of converting RegisterPass<> to INTIALIZE_PASS().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109045 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a9db12973005881a1bd1c5eddc31001d9c3189c8 15-Jul-2010 Dan Gohman <gohman@apple.com> Don't merge uses when they are targetting fixup sites with
different widths. In a use with a narrower fixup, formulae
may be wider than the fixup, in which case the high bits
aren't necessarily meaningful, so it isn't safe to reuse
them for uses with wider fixups.

This fixes PR7618, though the testcase is too large for a
reasonable regression test, since it heavily dependes on
hitting LSR's heuristics in a certain way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108455 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ef4308d6ba6a57c8a311fcabe078422aea3fc90a 15-Jul-2010 Dan Gohman <gohman@apple.com> Use dbgs() instead of errs() in a DEBUG.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108453 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c88c1a4581a4c73657892ef4ed72f1c9f72ed7ff 15-Jul-2010 Dan Gohman <gohman@apple.com> Watch out for a constant offset cancelling out a base register, forming
a zero. This situation arrises in Fortran code with induction variables
that start at 1 instead of 0. This fixes PR7651.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108424 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ad72e731366b99aa52d92607d8a4b7a8c26fa632 30-Jun-2010 Gabor Greif <ggreif@gmail.com> use getArgOperand instead of getOperand

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107270 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3e3f15bb09eaca4d259e531c9a1ecafb5710b57b 26-Jun-2010 Dan Gohman <gohman@apple.com> In GenerateReassociations, don't bother thinking about individual
SCEVUnknown values which are loop-variant, as LSR can't do anything
interesting with these values in any case. This fixes very slow compile
times on loops which have large numbers of such values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106897 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2ea09e05466613a22e1211f52c30cd01af563983 24-Jun-2010 Dan Gohman <gohman@apple.com> A few minor micro-optimizations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106764 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d42819a07b052e68c6967c10c35a81eb808c5018 24-Jun-2010 Dan Gohman <gohman@apple.com> Teach getExactSDiv to evaluate x/1 to x up front, as it's a common
enough special case, and it theoretically allows more folding because
it works even when x is unanalyzable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106763 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
473e63512acb3751da7dffbb10e0452cb581b265 24-Jun-2010 Dan Gohman <gohman@apple.com> Fix copy+pasto issues in isMulSExtable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106759 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
caf71ab4735d6b80300cf123a8c3c0759d2e2873 23-Jun-2010 Dan Gohman <gohman@apple.com> Fix OptimizeMax to handle an odd case where one of the max operands
is another max which folds. This fixes PR7454.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106594 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
403a8cdda5e76ea689693de16474650b4b0df818 21-Jun-2010 Dan Gohman <gohman@apple.com> Use A.append(...) instead of A.insert(A.end(), ...) when A is a
SmallVector, and other SmallVector simplifications.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106452 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
74e5ef096ee53586ae8798c35d64e5974345c187 19-Jun-2010 Dan Gohman <gohman@apple.com> Add a TODO comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106397 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1e3121c80a02359fda87cf77ce1fd7bbd5066991 19-Jun-2010 Dan Gohman <gohman@apple.com> Include the use kind along with the expression in the key of the
use sharing map. The reconcileNewOffset logic already forces a
separate use if the kinds differ, so incorporating the kind in the
key means we can track more sharing opportunities.

More sharing means fewer total uses to track, which means smaller
problem sizes, which means the conservative throttles don't kick
in as often.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106396 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b6211710acdf558b3b45c2d198e74aa602496893 19-Jun-2010 Dan Gohman <gohman@apple.com> Don't include things in anonymous namespaces that don't need it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106395 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a15ec5dfccace52bcfb31733e0412801a1ae3915 05-Jun-2010 Dan Gohman <gohman@apple.com> Don't track users of undef values; they aren't interesting for
register pressure.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105501 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0fe46d9b480ab4851e1fc8bc589d1ed9c8b2a70e 21-May-2010 Dan Gohman <gohman@apple.com> DominatorTree.getNode can return null for unreachable blocks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104290 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9f383eb9503580a1425073beee99fdf74ed31a17 21-May-2010 Dan Gohman <gohman@apple.com> Minor code cleanups.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104287 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a5528785089bfd093a36cbc2eddcc35980c5340e 20-May-2010 Dan Gohman <gohman@apple.com> Make Solve check its own post-condition, to reduce clutter in the
top-level LSRInstance logic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104278 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
76c315a26c9c6eb51fca2d88ee756094bed3b846 20-May-2010 Dan Gohman <gohman@apple.com> Add comments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104276 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
402d43529c18d662d1964d70dbf55bc135a8b473 20-May-2010 Dan Gohman <gohman@apple.com> More code cleanups. Use iterators instead of indices when indices
aren't needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104273 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c6519f916b5922de81c53547fd21364994195a70 20-May-2010 Dan Gohman <gohman@apple.com> Fix OptimizeShadowIV to set Changed. Change OptimizeLoopTermCond to set
Changed directly instead of using a return value.

Rename FilterOutUndesirableDedicatedRegisters's Changed variable to
distinguish it from LSRInstance's Changed member.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104269 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f7ff37d6745bfe170458e1165a5109cd2432d99d 20-May-2010 Dan Gohman <gohman@apple.com> Add some comments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104268 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d974a0e9d682e627f100340a8021e02ca991f965 20-May-2010 Dan Gohman <gohman@apple.com> Simplify this code. Don't do a DomTreeNode lookup for each visited block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104267 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ea507f5c28e4c21addb4022a6a2ab85f49f172e3 20-May-2010 Dan Gohman <gohman@apple.com> Minor code cleanups.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104263 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f182b23f8fed014c26da48d94890080c7d916a0c 20-May-2010 Dan Gohman <gohman@apple.com> When canonicalizing icmp operand order to put the loop invariant
operand on the left, the interesting operand is on the right. This
fixes a bug where LSR was failing to recognize ICmpZero uses,
which led it to be unable to reverse the induction variable in the
attached testcase.

Delete test/CodeGen/X86/stack-color-with-reg-2.ll, because its test
is extremely fragile and hard to meaningfully update.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104262 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9da1bf4845e670096b9bf9e62c40960af1697ea0 20-May-2010 Dan Gohman <gohman@apple.com> Set Changed to true when canonicalizing ICmp operand order; even though
it isn't a very interesting change, it's a change nonetheless.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104260 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
24a7c3082288755bef6a8124e384ff8b52d31e49 20-May-2010 Dan Gohman <gohman@apple.com> Rename a variable to avoid shadowing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104234 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4766744072a65558344e6afdd4b42fc196ce47f4 20-May-2010 Dan Gohman <gohman@apple.com> Minor code simplification.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104232 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5ce6d05ad6b500a6262211674e51b8d0598714d3 20-May-2010 Dan Gohman <gohman@apple.com> Move the code for deleting BaseRegs and LSRUses into helper functions,
and fix a bug that valgrind noticed where the code would std::swap an
element with itself.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104225 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a2086b3483b88b5b64f098b6644e450f94933f49 20-May-2010 Dan Gohman <gohman@apple.com> Teach LSR how to cope better with unrolled loops on targets where
the addressing modes don't make this trivially easy. This allows
it to avoid falling into the less precise heuristics in more
cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104186 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
57aaa0b264d9d23d9a14235334b15d4117e32a3b 19-May-2010 Dan Gohman <gohman@apple.com> Add a comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104089 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
360026f07fcf35eee9fcfbf7b9c1afda41d4b148 19-May-2010 Dan Gohman <gohman@apple.com> Fix the predicate which checks for non-sensical formulae which have
constants in registers which partially cancel out their immediate fields.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104088 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b2df433f713c5ae9ddf95bd9d47cb3e7b0c6c8ba 19-May-2010 Dan Gohman <gohman@apple.com> Factor out the code for recomputing an LSRUse's Regs set after some
of its formulae have been removed into a helper function, and also
teach it how to update the RegUseTracker.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104087 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d079c300ed138fb391b2d1c955f36311c92aeaea 19-May-2010 Dan Gohman <gohman@apple.com> Factor out code for estimating search space complexity into a helper
function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104082 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0da751baf72542ab66518e4549e39da5f34216b4 19-May-2010 Dan Gohman <gohman@apple.com> Add some more debug output.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104080 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d69d62833a66691e96ad2998450cf8c9f75a2e8c 19-May-2010 Dan Gohman <gohman@apple.com> Factor out the code for deleting a formula from an LSRUse into
a helper function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104079 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6458ff9230a53bb9c442559074fac2611fb70bbf 19-May-2010 Dan Gohman <gohman@apple.com> Make some debug output more informative.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104078 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c4cfbaf2174bc0b0aef080b183b048c9f05c4725 19-May-2010 Dan Gohman <gohman@apple.com> Print an error message in Formula::print if the HasBaseReg flag
is inconsistent with the BaseRegs field. It's not print's job to
assert on an invalid condition, but it can make one more obvious.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104077 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
90bb355b162ec5a640554ee1dc3dda5ce9e50c50 19-May-2010 Dan Gohman <gohman@apple.com> Rename RegUseTracker's RegUses member to RegUsesMap to avoid
confusion with LSRInstance's RegUses member.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104076 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7d9663c70b3300070298d716dba6e6f6ce2d1e3e 11-May-2010 Douglas Gregor <dgregor@apple.com> Fixes for Microsoft Visual Studio 2010, from Steven Watanabe!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103457 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
59dc60337fb9c02c4fbec3b44d7275a32bafa775 08-May-2010 Dan Gohman <gohman@apple.com> When pruning candidate formulae out of an LSRUse, update the
LSRUse's Regs set after all pruning is done, rather than trying
to do it on the fly, which can produce an incomplete result.

This fixes a case where heuristic pruning was stripping all
formulae from a use, which led the solver to enter an infinite
loop.

Also, add a few asserts to diagnose this kind of situation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103328 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
deff621abdd48bd70434bd4d7ef30f08ddba1cd8 04-May-2010 Dan Gohman <gohman@apple.com> Use getConstant instead of getIntegerSCEV. The two are basically the
same, now that getConstant has overloads consistent with ConstantInt::get.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102965 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1d367988e21bb1b4e8346877f8fa377dff194c29 24-Apr-2010 Dan Gohman <gohman@apple.com> Generalize LSR's OptimizeMax to handle the new kinds of max expressions
that indvars may use, now that indvars is recognizing le and ge loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102235 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
fafb890ee204d60456d0780ff55a149fa082eaea 23-Apr-2010 Dan Gohman <gohman@apple.com> Fix LSR to tolerate cases where ScalarEvolution initially
misses an opportunity to fold add operands, but folds them
after LSR has separated them out. This fixes rdar://7886751.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102157 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c056454ecfe66f7c646fedef594f4ed48a9f3bf0 19-Apr-2010 Dan Gohman <gohman@apple.com> Remove the Expr member from IVUsers. Instead of remembering the expression,
just ask ScalarEvolution for it on demand. This helps IVUsers be more robust
in the case of expressions changing underneath it. This fixes PR6862.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101819 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ef817ccec44fd960d80cd6129aec1a1622cbe9f7 12-Apr-2010 Dan Gohman <gohman@apple.com> Delete this code, which is no longer needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101033 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e5f76877aee6f33964de105893f0ef338661ecad 10-Apr-2010 Dan Gohman <gohman@apple.com> When determining a canonical insert position, don't climb deeper
into adjacent loops. Also, ensure that the insert position is
dominated by the loop latch of any loop in the post-inc set which
has a latch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100906 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4a2a68336638e99a475b09a9278399db6749618f 09-Apr-2010 Dan Gohman <gohman@apple.com> When looking for loop-invariant users, look through no-op instructions,
so that an unfortunately placed bitcast doesn't pin a value in a
register.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100883 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d96eae80107a0881e21d1dda97e5e848ed055ec2 09-Apr-2010 Dan Gohman <gohman@apple.com> Refactor the code for computing the insertion point for an expression into
a separate function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100845 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e60bb15982dc40517e078c3858fdc0716d43abb5 09-Apr-2010 Dan Gohman <gohman@apple.com> Avoid allocating a value of zero in a register if the initial formula
inputs happen to negate each other.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100828 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e05678132345eb8a632362dbd320ee7d36226e67 09-Apr-2010 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
701a4aef7fa0ece4dc1fdbc88b981820564cb4e4 08-Apr-2010 Dan Gohman <gohman@apple.com> When expanding expressions which are using post-inc mode for multiple loops,
ensure that the expansion is dominated by the increments of those loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100748 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
448db1cdef5872713ef77beffacf502ae3450cd7 08-Apr-2010 Dan Gohman <gohman@apple.com> Generalize IVUsers to track arbitrary expressions rather than expressions
explicitly split into stride-and-offset pairs. Also, add the
ability to track multiple post-increment loops on the same expression.

This refines the concept of "normalizing" SCEV expressions used for
to post-increment uses, and introduces a dedicated utility routine for
normalizing and denormalizing expressions.

This fixes the expansion of expressions which are post-increment users
of more than one loop at a time. More broadly, this takes LSR another
step closer to being able to reason about more than one loop at a time.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100699 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
449f31cb9dbf4762935b63946e8120dbe98808ff 26-Mar-2010 Dan Gohman <gohman@apple.com> Ignore debug intrinsics in yet more places.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99580 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
60ad781c61815ca5b8dc2a45a102e1c8af65992f 26-Mar-2010 Gabor Greif <ggreif@gmail.com> rename use_const_iterator to const_use_iterator for consistency's sake

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99564 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
087bd1e3a12893873761736bf0f905a350e9e708 03-Mar-2010 Dan Gohman <gohman@apple.com> Make SCEVExpander and LSR more aggressive about hoisting expressions out
of loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97642 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
069d6f3396856655d5d4ba155ee16eb0209d38b0 02-Mar-2010 Dan Gohman <gohman@apple.com> Non-affine post-inc SCEV expansions have more code which must be
emitted after the increment. Make sure the insert position
reflects this. This fixes PR6453.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97537 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3f46a3abeedba8d517b4182de34c821d752db058 01-Mar-2010 Dan Gohman <gohman@apple.com> Spelling fixes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97453 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
454d26dc43207ec537d843229db6f5e6a302e23d 22-Feb-2010 Dan Gohman <gohman@apple.com> Remove unused variables and parameters.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96780 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
278f958c61e973975bf63b7a82f3d8322ea16c00 22-Feb-2010 Dan Gohman <gohman@apple.com> When emitting an instruction which depends on both a post-incremented
induction variable value and a loop-variant value, don't force the
insert position to be at the post-increment position, because it may
not be dominated by the loop-variant value. This fixes a
use-before-def problem noticed on PPC.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96774 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f09b71233bc43cfcca5199e355cc1129f7c4f89a 19-Feb-2010 Dan Gohman <gohman@apple.com> Rename getSDiv to getExactSDiv to reflect its behavior in cases where
the division would have a remainder.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96693 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
aae01f17a639f863e73dcadd80ad690fdc37b468 19-Feb-2010 Dan Gohman <gohman@apple.com> Check for overflow when scaling up an add or an addrec for
scaled reuse.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96692 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1b7bf18def8db328bb4efa02c0958ea399e8d8cb 19-Feb-2010 Dan Gohman <gohman@apple.com> When determining the set of interesting reuse factors, consider
strides in foreign loops. This helps locate reuse opportunities
with existing induction variables in foreign loops and reduces
the need for inserting new ones. This fixes rdar://7657764.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96629 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
378c0b35a7b9884f1de2a9762825424fbf1813ac 17-Feb-2010 Dan Gohman <gohman@apple.com> Delete some unneeded casts.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96429 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
968cb939e5a00cb06aefafc89581645790c590b3 17-Feb-2010 Dan Gohman <gohman@apple.com> Don't attempt to divide INT_MIN by -1; consider such cases to
have overflowed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96428 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3a02cbcd0310e6c63a4ac9b8d25fffc258c8b3e4 16-Feb-2010 Dan Gohman <gohman@apple.com> Refactor rewriting for PHI nodes into a separate function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96382 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7fca2294dad873aa7873e338ec3fcc4db49ea074 16-Feb-2010 Dan Gohman <gohman@apple.com> Fix whitespace.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96372 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1df9859c40492511b8aa4321eb76496005d3b75b 16-Feb-2010 Duncan Sands <baldrick@free.fr> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c2385a0741c43bd93eb2033e2f11eaae83cdb1cb 16-Feb-2010 Dan Gohman <gohman@apple.com> Split the main for-each-use loop again, this time for GenerateTruncates,
as it also peeks at which registers are being used by other uses. This
makes LSR less sensitive to use-list order.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96308 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
441a38993e89104c424e00c95cce63c7351f4fc3 14-Feb-2010 Dan Gohman <gohman@apple.com> Fix whitespace.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96179 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6020d85c41987b0b7890d91bf66187aac6e8a3a1 14-Feb-2010 Dan Gohman <gohman@apple.com> Fix a comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96178 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ce947366ec07ed3e9b017f0f4a07fa668a799119 14-Feb-2010 Dan Gohman <gohman@apple.com> When complicated expressions are broken down into subexpressions
with multiplication by constants distributed through, occasionally
those subexpressions can include both x and -x. For now, if this
condition is discovered within LSR, just prune such cases away,
as they won't be profitable. This fixes a "zero allocated in a
base register" assertion failure.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96177 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
590bfe8641631c136160fed7a9df9fe805938cbe 14-Feb-2010 Dan Gohman <gohman@apple.com> Actually, this code doesn't have to be quite so conservative in
the no-TLI case. But it should still default to declining the
transformation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96152 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2763dfdc701964a01c4a0386fadd1c4e92be9021 14-Feb-2010 Dan Gohman <gohman@apple.com> Don't attempt aggressive post-inc uses if TargetLowering is not available,
because profitability can't be sufficiently approximated.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96148 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6d09ab8ba2217bcf5a55f0c421d4787e223fc91b 14-Feb-2010 John McCall <rjmccall@apple.com> Make LSR not crash if invoked without target lowering info, e.g. if invoked
from opt.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96135 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9214b82c5446791b280821bbd892dca633130f80 13-Feb-2010 Dan Gohman <gohman@apple.com> Fix a pruning heuristic which implicitly assumed that SmallPtrSet is
deterministically sorted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96071 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
68d6da1f33be3f0a55f7fa87204069cfa79247c6 12-Feb-2010 Dan Gohman <gohman@apple.com> Reapply 95979, a compile-time speedup, now that the bug it exposed is fixed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96005 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
cd045c08cad9bc3e1e3e234453f5f4464b705e02 12-Feb-2010 Dan Gohman <gohman@apple.com> Fix this code to avoid dereferencing an end() iterator in
offset distributions it doesn't expect.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96002 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ae086250853cb901d59943bd98aa9a0ad9a85b4d 12-Feb-2010 Daniel Dunbar <daniel@zuster.org> Revert "Reverse the order for collecting the parts of an addrec. The order", it
is breaking llvm-gcc bootstrap.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95988 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f21a2f15aa967f16c2b8c71da3009c583890a059 12-Feb-2010 Dan Gohman <gohman@apple.com> Reverse the order for collecting the parts of an addrec. The order
doesn't matter, except that ScalarEvolution tends to need less time
to fold the results this way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95979 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
572645cf84060c0fc25cb91d38cb9079918b3a88 12-Feb-2010 Dan Gohman <gohman@apple.com> Reapply the new LoopStrengthReduction code, with compile time and
bug fixes, and with improved heuristics for analyzing foreign-loop
addrecs.

This change also flattens IVUsers, eliminating the stride-oriented
groupings, which makes it easier to work with.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95975 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
466f37befba81bea849a08f21d0a80fb6070ab8f 29-Jan-2010 Bill Wendling <isanbard@gmail.com> Generic reformatting and comment fixing. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94771 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9f9113a44bbca4890184003a997cd9ddb5472d38 29-Jan-2010 Bill Wendling <isanbard@gmail.com> Add newline to debugging output, and fix some grammar-os in comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94765 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7979b72febb73f7bb1d1ed095a68f210822b2e7c 22-Jan-2010 Dan Gohman <gohman@apple.com> Revert LoopStrengthReduce.cpp to pre-r94061 for now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94123 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
eca35b76cec713abb932eb016198b24a1acae314 22-Jan-2010 Dan Gohman <gohman@apple.com> When inserting expressions for post-increment users which contain
loop-variant components, adds must be inserted after the increment.
Keep track of the increment position for this case, and insert
these adds in the correct location.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94110 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
940bd3e23666b44797270b0b0cd0609f74166980 21-Jan-2010 Dan Gohman <gohman@apple.com> Include IVUsers information in LSR's debug output.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94108 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
8b0ade3eb8281f9b332d5764cfe5c4ed3b2b32d8 21-Jan-2010 Dan Gohman <gohman@apple.com> Prune the search for candidate formulae if the number of register
operands exceeds the number of registers used in the initial
solution, as that wouldn't lead to a profitable solution anyway.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94107 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2f524587b6cf1edf6b5715a234324fd0386fac42 21-Jan-2010 Dan Gohman <gohman@apple.com> Add a comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94104 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a10756ee657a4d43a48cca5c166919093930ed6b 21-Jan-2010 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9fff2187a21f765ed87a25c48552a6942450f3e2 05-Jan-2010 Dan Gohman <gohman@apple.com> Set Changed properly after calling DeleteDeadPHIs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92735 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
63c9463c62fce8cbe02176dfa2d73f375a06f1f2 23-Dec-2009 David Greene <greened@obbligato.org> Remove dump routine and the associated Debug.h from a header. Patch up
other files to compensate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92075 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
92329c7fbe572892c17aa2d2542a10e3ea16132f 18-Dec-2009 Dan Gohman <gohman@apple.com> Add Loop contains utility methods for testing whether a loop
contains another loop, or an instruction. The loop form is
substantially more efficient on large loops than the typical
code it replaces.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91654 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3ca735450db584068f07b728f0537c3e9208a699 18-Dec-2009 Dan Gohman <gohman@apple.com> Minor code simplification.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91653 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6a27e1550dd52b0b47431eb6956f35f65c2349f6 18-Dec-2009 Dan Gohman <gohman@apple.com> Don't pass const pointers by reference.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91647 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6bec5bb344fc0374431aed1cb63418de607a1aec 18-Dec-2009 Dan Gohman <gohman@apple.com> Reapply LoopStrengthReduce and IVUsers cleanups, excluding the part
of 91296 that caused trouble -- the Processed list needs to be
preserved for the livetime of the pass, as AddUsersIfInteresting
is called from other passes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91641 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
04149f7ffd033773adfe85e4acf3f560e29bd47d 17-Dec-2009 Evan Cheng <evan.cheng@apple.com> Revert 91280-91283, 91286-91289, 91291, 91293, 91295-91296. It apparently introduced a non-deterministic behavior in the optimizer somewhere.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91598 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a0cefcfcac7f96f3ce4b0cbee8a282124433cd00 15-Dec-2009 Dan Gohman <gohman@apple.com> Delete an unused function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91432 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
30844c3950ee869eb430ce718b5a994fabed7aa7 14-Dec-2009 Dan Gohman <gohman@apple.com> Fix a thinko; isNotAlreadyContainedIn had a built-in negative, so the
condition was inverted when the code was converted to contains().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91295 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c71c0e958c55bbf389ba27edfa9a7d4206a8fe2c 14-Dec-2009 Dan Gohman <gohman@apple.com> Remove unnecessary #includes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91293 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d3222b42249aaa1aee17662c2d5669c0dc6c1d14 14-Dec-2009 Dan Gohman <gohman@apple.com> Instead of having a ScalarEvolution pointer member in BasedUser, just pass
the ScalarEvolution pointer into the functions which need it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91289 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a77d588c752bbf5d339f674af50733c10b113d0a 14-Dec-2009 Dan Gohman <gohman@apple.com> Don't bother cleaning up if there's nothing to clean up.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91288 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6dc1ef392348b61f228612f24087f47d4e4e2982 14-Dec-2009 Dan Gohman <gohman@apple.com> Delete an unused variable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91287 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1ed8bb35564abbe5a74fe6c24b2e232e7f810e4e 14-Dec-2009 Dan Gohman <gohman@apple.com> LSR itself doesn't need LoopInfo.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91283 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c3983653493a97d0da49cea6829348380c4717b8 14-Dec-2009 Dan Gohman <gohman@apple.com> LSR itself doesn't need DominatorTree.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91282 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
67b94fb73d3cc1b93348b3a5675ad395b9f27227 14-Dec-2009 Dan Gohman <gohman@apple.com> Remove the code in LSR that manually hoists expansions out of loops;
SCEVExpander does this automatically.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91281 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b058ceda5689b790cb05c33270da35c74dc06e48 14-Dec-2009 Dan Gohman <gohman@apple.com> Minor code cleanups.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91280 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
502309579962fe592c445d293119f5949edbcbdf 17-Nov-2009 Jim Grosbach <grosbach@apple.com> grammar

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89145 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
464ecfee71e33f3a00b42da1ba7838a6852c95fb 17-Nov-2009 Jim Grosbach <grosbach@apple.com> 80-column violations

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89123 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
076e085698c484354c9e131f1bd8fd001581397b 17-Nov-2009 Evan Cheng <evan.cheng@apple.com> Generalize OptimizeLoopTermCond to optimize more loop terminating icmp to use postinc iv.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89116 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
56a1f806aff00a8be6db4eb5c9cd5c751ff0f4c1 17-Nov-2009 Jim Grosbach <grosbach@apple.com> Remove trailing whitespace

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89110 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
586f69a11881d828c056ce017b3fb432341d9657 12-Nov-2009 Evan Cheng <evan.cheng@apple.com> - Teach LSR to avoid changing cmp iv stride if it will create an immediate that
cannot be folded into target cmp instruction.
- Avoid a phase ordering issue where early cmp optimization would prevent the
later count-to-zero optimization.
- Add missing checks which could cause LSR to reuse stride that does not have
users.
- Fix a bug in count-to-zero optimization code which failed to find the pre-inc
iv's phi node.
- Remove, tighten, loosen some incorrect checks disable valid transformations.
- Quite a bit of code clean up.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86969 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f40888dc9b2b1a28fb4e7ba9a1fc930461e251aa 11-Nov-2009 Evan Cheng <evan.cheng@apple.com> Block terminator may be a switch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86761 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
81ebdcf7dd3c182f5fca352b59b336f79d5da23e 10-Nov-2009 Evan Cheng <evan.cheng@apple.com> Generalize lsr code that optimize loop to count down towards zero.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86715 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
eb3567cd49b6767fb9b505591245f81b4341b9f2 06-Nov-2009 Dan Gohman <gohman@apple.com> Teach LSR to avoid calling SplitCriticalEdge on edges with indirectbr.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86193 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
03e896bd6073efc4523d8bcd0239d6ed62126db7 05-Nov-2009 Dan Gohman <gohman@apple.com> Update various Loop optimization passes to cope with the possibility that
LoopSimplify form may not be available.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86175 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a8225083ba7b2368cec0ced232e43dc77d5f6f0a 26-Oct-2009 Dan Gohman <gohman@apple.com> Make LSR's OptimizeShadowIV ignore induction variables with negative
strides for now, because it doesn't handle them correctly. This fixes a
miscompile of SingleSource/Benchmarks/Misc-C++/ray.

This problem was usually hidden because indvars transforms such induction
variables into negations of canonical induction variables.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85118 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4a134afaef984c403f6d6b1da4d301666d899b92 25-Oct-2009 Nick Lewycky <nicholas@mxc.ca> Remove ICmpInst::isSignedPredicate which was a reimplementation
CmpInst::isSigned.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85037 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6776064d190701c5bae4d5403939eed2e480d1cd 27-Sep-2009 Nick Lewycky <nicholas@mxc.ca> Instruction::clone does not need to take an LLVMContext&. Remove that and
update all the callers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82889 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5c89b5240c90eb8171f999e5f06f815502d0321c 08-Sep-2009 Dan Gohman <gohman@apple.com> Re-apply r80926, with fixes: keep the domtree informed of new blocks
that get created during loop unswitching, and fix SplitBlockPredecessors'
LCSSA updating code to create new PHIs instead of trying to just move
existing ones.

Also, optimize Loop::verifyLoop, since it gets called a lot. Use
searches on a sorted list of blocks instead of calling the "contains"
function, as is done in other places in the Loop class, since "contains"
does a linear search. Also, don't call verifyLoop from LoopSimplify or
LCSSA, as the PassManager is already calling verifyLoop as part of
LoopInfo's verifyAnalysis.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81221 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
8f78a58e14fa754cde827e46ad03f00c7a6ead01 06-Sep-2009 Evan Cheng <evan.cheng@apple.com> Revert r80926. It causes loop unswitch assertion and slow down some JIT tests significantly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81101 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
8fc5ad33691b2a0672a7487da1f56b6f7f675a1b 03-Sep-2009 Dan Gohman <gohman@apple.com> Add a verifyAnalysis to LoopInfo, LoopSimplify, and LCSSA form that verify
that these passes are properly preserved.

Fix several transformation passes that claimed to preserve LoopSimplify
form but weren't.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80926 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3e8b6631e67e01e4960a7ba4668a50c596607473 02-Sep-2009 Chris Lattner <sabre@nondot.org> eliminate VISIBILITY_HIDDEN from Transforms/Scalar. PR4861


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80766 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
bdff548e4dd577a72094d57b282de4e765643b96 23-Aug-2009 Chris Lattner <sabre@nondot.org> eliminate the "Value" printing methods that print to a std::ostream.
This required converting a bunch of stuff off DOUT and other cleanups.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79819 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1d0be15f89cb5056e20e2d24faa8d6afb1573bca 13-Aug-2009 Owen Anderson <resistor@mac.com> Push LLVMContexts through the IntegerType APIs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78948 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e50ed30282bb5b4a9ed952580523f2dda16215ac 11-Aug-2009 Owen Anderson <resistor@mac.com> Rename MVT to EVT, in preparation for splitting SimpleValueType out into its own struct type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78610 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3fe14bf15338866b21784a64b78e53b5801523c8 05-Aug-2009 Dan Gohman <gohman@apple.com> Check for !isa<Constant> instead of isa<Instruction>. This
matches what the comment says, and it avoids spurious BitCast
instructions for Argument values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78121 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a7235ea7245028a0723e8ab7fd011386b3900777 31-Jul-2009 Owen Anderson <resistor@mac.com> 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77721 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f485b3bbab86274161e2b56e829b404cce227675 30-Jul-2009 Douglas Gregor <dgregor@apple.com> Eliminate a few unused-variable warnings

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77519 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
debcb01b0f0a15f568ca69e8f288fade4bfc7297 30-Jul-2009 Owen Anderson <resistor@mac.com> Move types back to the 2.5 API.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77516 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
baf3c404409d5e47b13984a7f95bfbd6d1f2e79e 29-Jul-2009 Owen Anderson <resistor@mac.com> Move ConstantExpr to 2.5 API.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77494 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6f83c9c6ef0e7f79825a0a8f22941815e4b684c7 27-Jul-2009 Owen Anderson <resistor@mac.com> Move ConstantFP construction back to the 2.5-ish API.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77247 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
460f656475738d1a95a6be95346908ce1597df25 26-Jul-2009 Daniel Dunbar <daniel@zuster.org> Remove Value::getName{Start,End}, the last of the old Name APIs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77152 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
eed707b1e6097aac2bb6b3d47271f6300ace7f2e 25-Jul-2009 Owen Anderson <resistor@mac.com> Revert the ConstantInt constructors back to their 2.5 forms where possible, thanks to contexts-on-types. More to come.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77011 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e922c0201916e0b980ab3cfe91e1413e68d55647 22-Jul-2009 Owen Anderson <resistor@mac.com> Get rid of the Pass+Context magic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76702 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c8d76d5afb023a1c6b439941be3b62789fcc0ed3 13-Jul-2009 Dan Gohman <gohman@apple.com> 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75519 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
333c40096561218bc3597cf153c0a3895274414c 10-Jul-2009 Owen Anderson <resistor@mac.com> This started as a small change, I swear. Unfortunately, lots of things call the [I|F]CmpInst constructors. Who knew!?


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75200 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0bba49cebc50c7bd4662a4807bcb3ee7f42cb470 07-Jul-2009 Dan Gohman <gohman@apple.com> Change all SCEV* to SCEV *.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74918 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1ff50b380e6f5549f5ddd9e6c390dcb00332e3e9 03-Jul-2009 Owen Anderson <resistor@mac.com> Second batch of passes using LLVMContext.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74753 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
40a5a1b39ee1cd40ff9d04740386b667fb27b340 24-Jun-2009 Dan Gohman <gohman@apple.com> 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74048 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ea080be98625d86dc0a574f71d7df69e2351734c 24-Jun-2009 Dan Gohman <gohman@apple.com> Don't emit a redundant BitCastInst if the value to be defined in the
preheader is already an instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74031 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
372b46cad9f745859f542f9d2216991585ae83f4 22-Jun-2009 Owen Anderson <resistor@mac.com> SCEVHandle is no more!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73906 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5392dce8815bc8975076a6b4f0079359878e2b7a 22-Jun-2009 Dan Gohman <gohman@apple.com> Rename a variable for consistency with the ExitBlock vs ExitingBlock
terminology that LoopInfo uses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73863 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
224a19c490da17c6ed75245a4a7ef49cd25f6cdf 20-Jun-2009 Dan Gohman <gohman@apple.com> Fix a typo in a comment that Frits von Bommel noticed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73796 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2781f30eac8647552638246c28ab07dd0fc2c560 20-Jun-2009 Dan Gohman <gohman@apple.com> Re-apply r73718, now that the fix in r73787 is in, and add a
hand-crafted testcase which demonstrates the bug that was exposed
in 254.gap.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73793 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4d1c1efd800727165c12c2d186a5cb0b4f5834ab 20-Jun-2009 Dan Gohman <gohman@apple.com> Fix LSR's OptimizeSMax to ignore max operators with more than 2 operands,
which it isn't prepared to handle.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73787 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
73a76736fbae602563e1c7dab3658c005caa2c09 19-Jun-2009 Evan Cheng <evan.cheng@apple.com> Revert 73718. It's breaking 254.gap.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73783 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4658c9b4eaa89f00f682a7510b83e7d4895fe18f 18-Jun-2009 Dan Gohman <gohman@apple.com> Generalize LSR's OptimizeSMax to handle unsigned max tests as well
as signed max tests. Along with r73717, this helps CodeGen avoid
emitting code for a maximum operation for this class of loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73718 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4e8a98519ebf75ed47456ea42706aaa57ecd2c27 18-Jun-2009 Dan Gohman <gohman@apple.com> 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73706 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e3a6165423503f550b4f60e06469ad6420a585c9 17-Jun-2009 Dan Gohman <gohman@apple.com> Update comments to use doxygen syntax.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73621 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6de29f8d960505421d61c80cdb738e16720b6c0e 16-Jun-2009 Dan Gohman <gohman@apple.com> 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73431 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a82752c9eb5fbdd1b7276fde7349ac9453eb5a75 15-Jun-2009 Dan Gohman <gohman@apple.com> Convert several parts of the ScalarEvolution framework to use
SmallVector instead of std::vector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73357 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
da634298fc5243932274ae261efcd351d5040630 06-Jun-2009 Devang Patel <dpatel@apple.com> Simplify.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72965 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ae3a0be92e33bc716722aa600983fc1535acb122 05-Jun-2009 Dan Gohman <gohman@apple.com> 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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72897 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c2695eba5700c785c2ae144eede7e1a932e3f5f3 27-May-2009 Dan Gohman <gohman@apple.com> Revert 72493 and replace it with a more conservative fix, for now: don't
rewrite the comparison if there is any implicit extension or truncation
on the induction variable. I'm planning for IVUsers to eventually take
over some of the work of this code, and for it to be generalized.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72496 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ead28bd04bf42cdf8c29d12fa4c0f9d29a4c58cd 27-May-2009 Dan Gohman <gohman@apple.com> In ChangeCompareStride, when the stride to be reused is truncated to
a smaller type, promoted its offset back up to the type of the new
comparison. This fixes PR4222.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72493 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
513fae2db51c7d22ec1253e89939d27732b21a5e 20-May-2009 Dan Gohman <gohman@apple.com> Suppress the IV reversal transformation in the case that the RHS
of the comparison is defined inside the loop. This fixes a
use-before-def problem, because the transformation puts a use
of the RHS outside the loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72149 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
cec8f9da54d3017e27c46ced38b859136655c198 19-May-2009 Dan Gohman <gohman@apple.com> Add some more comments to the top of this file.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72131 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6bfa57b3b3affa6a91645d9b60d84f4ca85f250f 19-May-2009 Dan Gohman <gohman@apple.com> Trim unneeded #includes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72130 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5be18e84766fb495b0bde3c8244c1df459a18683 19-May-2009 Dan Gohman <gohman@apple.com> 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72093 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a537bf83eda87a0eb65c278d673e51f76b0dd98b 18-May-2009 Dan Gohman <gohman@apple.com> Rename UseTy to AccessTy, for consistency with getAccessType, and to
avoid ambiguity with the word "use" in IVStrideUse.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72012 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7b9486ad4355a010d22e0737cee9cd7c7b747ece 13-May-2009 Dale Johannesen <dalej@apple.com> Add an int64_t variant of abs, for host environments
without one. Use it where we were using abs on
int64_t objects.
(I strongly suspect the casts to unsigned in the
fragments in LoopStrengthReduce are not doing whatever
the original intent was, but the obvious change to
uint64_t doesn't work. Maybe later.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71612 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
81db61a2e6d3c95a2738c3559a108e05e9d7a05a 12-May-2009 Dan Gohman <gohman@apple.com> 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71535 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5792f51e12d9c8685399e9857799365854ab5bf6 12-May-2009 Evan Cheng <evan.cheng@apple.com> Teach LSR to optimize more loop exit compares, i.e. change them to use postinc iv value. Previously LSR would only optimize those which are in the loop latch block. However, if LSR can prove it is safe (and profitable), it's now possible to change those not in the latch blocks to use postinc values.

Also, if the compare is the only use, LSR would place the iv increment instruction before the compare instead in the latch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71485 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c1acc3f764804d25f70d88f937ef9c460143e0f1 11-May-2009 Dale Johannesen <dalej@apple.com> Reverse a loop that is counting up to a maximum to
count down to 0 instead, under very restricted
circumstances. Adjust 4 testcases in which this
optimization fires.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71439 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2d85052f2bae5a5a31c03017c48ca8a9eba1453c 09-May-2009 Evan Cheng <evan.cheng@apple.com> Factor out code that optimize loop terminating condition.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71305 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ee08da89565714ca143d4754f167e3277974fc19 06-May-2009 Evan Cheng <evan.cheng@apple.com> Unbreak the build.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71091 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e19c840d6c6fe075b61a21a0f6abe338afba666d 06-May-2009 David Greene <greened@obbligato.org> Make sure to use signed arithmetic in APInt to fix a regression.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71090 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ce174f8e15774546e9bd276f17cb4b7c74274a93 06-May-2009 Dan Gohman <gohman@apple.com> Fix a copy+pasto in a comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71035 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4221ae84ef45c2099cbb7a61625e8260f37df275 06-May-2009 Dan Gohman <gohman@apple.com> Delete a FIXME which is no longer relevant, and add a FIXME that is.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71033 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a48941087bc5c176556d5f24e255e58936a0e14c 05-May-2009 Bill Wendling <isanbard@gmail.com> Temporarily reverting r71008. It was causing this failure:

Running /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/test/
CodeGen/X86/dg.exp ...
FAIL: /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/test/
CodeGen/X86/change-compare-stride-1.ll
Failed with exit(1) at line 2
while running: grep {cmpq $-478,} change-compare-stride-1.ll.tmp
child process exited abnormally



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71013 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
58deef5559db65f742fc67adcdaba04ce83f0764 05-May-2009 David Greene <greened@obbligato.org> Handle overflow of 64-bit loop conditions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71008 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
35738ac150afafe2359268d4b2169498c6c98c5f 05-May-2009 Dan Gohman <gohman@apple.com> 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70927 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
622ed671b90d449496d582b3a03c7aad1e98324a 05-May-2009 Dan Gohman <gohman@apple.com> Constify a bunch of SCEV-using code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70919 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f9a77b77c2324b2ca5c644909ebda387daf82fe3 03-May-2009 Dan Gohman <gohman@apple.com> Revert r70645 for now; it's causing a variety of regressions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70661 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
db6fa2964176c34f0e878e101427c28782c93419 02-May-2009 Dan Gohman <gohman@apple.com> 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70645 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
afc36a9520971832dfbebc0333593bf5d3098296 02-May-2009 Dan Gohman <gohman@apple.com> Previously, RecursivelyDeleteDeadInstructions provided an option
of returning a list of pointers to Values that are deleted. This was
unsafe, because the pointers in the list are, by nature of what
RecursivelyDeleteDeadInstructions does, always dangling. Replace this
with a simple callback mechanism. This may eventually be removed if
all clients can reasonably be expected to use CallbackVH.

Use this to factor out the dead-phi-cycle-elimination code from LSR
utility function, and generalize it to use the
RecursivelyDeleteTriviallyDeadInstructions utility function.

This makes LSR more aggressive about eliminating dead PHI cycles;
adjust tests to either be less trivial or to simply expect fewer
instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70636 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1dcad96dc68c8a4565f10759bcabc634f61243e0 02-May-2009 Dan Gohman <gohman@apple.com> Don't split critical edges during the AddUsersIfInteresting phase
of LSR. This makes the AddUsersIfInteresting phase of LSR a pure
analysis instead of a phase that potentially does CFG modifications.

The conditions where this code would actually perform a split are
rare, and in the cases where it actually would do a split the split
is usually undone by CodeGenPrepare, and in cases where splits
actually survive into codegen, they appear to hurt more often than
they help.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70625 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9f2d671b154e2b48b097d813b64a2bf2a33c547a 01-May-2009 Dan Gohman <gohman@apple.com> Make RequiresTypeConversion canonicalize the types before calling the
target hooks canLosslesslyBitCastTo and isTruncateFree. This allows
targets to avoid worrying about handling all combinations of integer
and pointer types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70555 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3d81e317244ecac40d1977221a4a521589b869f5 01-May-2009 Dan Gohman <gohman@apple.com> Minor whitespace fix.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70551 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
cc2ad058b378673e8cccba34b99857f8f72ff0e6 01-May-2009 Dan Gohman <gohman@apple.com> Fix some code to work if TargetLowering is not available.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70546 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
22523ad737456817c2edbd5047344b0a0d4c27bc 30-Apr-2009 Dale Johannesen <dalej@apple.com> Print correct instruction in dump.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70427 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c7749b747e634f310b7f0e075f7329dcb88f58cc 27-Apr-2009 Dan Gohman <gohman@apple.com> Permit ChangeCompareStride to rewrite a comparison when the factor
between the comparison's iv stride and the candidate stride is
exactly -1.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70244 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
84923602fdc2a81957e5dee178d5737ad8e72f55 21-Apr-2009 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
af79fb5f47b0088c6a8973a7fdbaea96973a429d 21-Apr-2009 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
890f92b744fb074465bc2b7006ee753a181f62a4 18-Apr-2009 Dan Gohman <gohman@apple.com> Use more const qualifiers with SCEV interfaces.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69450 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
edf7cf80d863c7a14f19383fd35cb122337696a8 17-Apr-2009 Dan Gohman <gohman@apple.com> Don't create ConstantInts with pointer type. This fixes a
regression in 403.gcc in PIC_CODEGEN=1 and DISABLE_LTO=1
mode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69344 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
84fc33ed920d55fe59544ec83f14d1abc5bf0d63 17-Apr-2009 Dan Gohman <gohman@apple.com> Use TargetData::getTypeSizeInBits instead of getPrimitiveSizeInBits()
to get the correct answer for pointer types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69321 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
65e05b69d60e67caad9ef70b24d4033d0e68b617 16-Apr-2009 Dan Gohman <gohman@apple.com> Minor code simplifications. Don't attempt LSR on theoretical
targets with pointers larger than 64 bits, due to the code not
yet being APInt clean.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69296 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
13317bc1e90efaed0c2e6da794f313aeadb226eb 16-Apr-2009 Dan Gohman <gohman@apple.com> LSR is no longer a GEP optimizer. It is now an IV expression
optimizer, which just happen to frequently involve optimizing GEPs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69295 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
798d3923e0c9f4d4f630ccdb92ed535631464a43 16-Apr-2009 Dan Gohman <gohman@apple.com> Use ConstantExpr::getIntToPtr instead of SCEVExpander::InsertCastOfTo,
since the operand is always a constant.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69291 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e616bf338a3669fad4bc3806547f70328eb2aa7e 16-Apr-2009 Dan Gohman <gohman@apple.com> Use a SCEV expression cast instead of immediately inserting a
new instruction with SCEVExpander::InsertCastOfTo.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69290 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2d1be87ee40a4a0241d94448173879d9df2bc5b3 16-Apr-2009 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b7e64ac3acac46ed42b5d099d59af73bedabb6fc 18-Mar-2009 Chris Lattner <sabre@nondot.org> LSR shouldn't ever try to hack on integer IV's larger than 64-bits. Right now
it is not APInt clean, but even when it is it needs to be evaluated carefully
to determine whether it is actually profitable.

This fixes a crash on PR3806


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67134 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9d10086797b4dfe58f8b13a71534b28805f0713d 09-Mar-2009 Dan Gohman <gohman@apple.com> Don't record the increment instruction; just recompute it from the Phi
if needed. This simplifies the code a little, and is needed for an
upcoming refactoring.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66479 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3cfe6a4bc2437a7286844ae9e1c0d3a83d6e8a23 09-Mar-2009 Dan Gohman <gohman@apple.com> Fix a few more places where induction variable types were used
where memory access types are needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66470 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
bb5b49cb8d1415685d194a7302ec6318f907160b 09-Mar-2009 Dan Gohman <gohman@apple.com> Use ReplacedTy instead of recomputing the same value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66469 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0daeed270bb0318b8a1337026fe92646a40ee3d9 09-Mar-2009 Dan Gohman <gohman@apple.com> Use LoopInfo's getLoopLatch() instead of doing what it does manualy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66467 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
53f2ae268ab0e9201c0c50c28a27d451497a0371 09-Mar-2009 Dan Gohman <gohman@apple.com> Don't use an induction variable type as a memory access type.
Use VoidTy instead, to be properly conservative.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66463 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
21e7722868378f67974e648ab21d0e3c69a0e379 09-Mar-2009 Dan Gohman <gohman@apple.com> Factor out the code that determines the memory access type
of an instruction into a helper function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66460 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f7912df4cbdb44aeac9ac9907c192dfc1e22646d 09-Mar-2009 Dan Gohman <gohman@apple.com> Move the sorting of the StrideOrder array earlier so that it doesn't
have to be done twice.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66449 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9f4ac31a9406c1f110e57b347689e15f64b33151 09-Mar-2009 Dan Gohman <gohman@apple.com> Delete the isOnlyStride argument, which is unused.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66446 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
80b0f8c0628d848d36f04440687b61e3b2d3dff1 09-Mar-2009 Dan Gohman <gohman@apple.com> Tidy some LSR debug output: announce the loop it's about to process
before it does any processing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66443 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
fd0339933b907a5118efdac6d7dc78ac92c0a8c8 04-Mar-2009 Dan Gohman <gohman@apple.com> Fix this comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66065 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
bc10b8c6c7e85e44d8231dfb2fb41a60300857e3 04-Mar-2009 Dan Gohman <gohman@apple.com> Add an assertion for a condition that's always true, and not
immediately obvious.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66062 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
46bdfb0e6bb9de86b19562fc52fddefd7014cf73 24-Feb-2009 Dan Gohman <gohman@apple.com> Rename ScalarEvolution's getIterationCount to getBackedgeTakenCount,
to more accurately describe what it does. Expand its doxygen comment
to describe what the backedge-taken count is and how it differs
from the actual iteration count of the loop. Adjust names and
comments in associated code accordingly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65382 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c34fea3935dcc0cab13cfb5cb60471bd49089230 24-Feb-2009 Dan Gohman <gohman@apple.com> Generalize the ChangeCompareStride code, in preparation for
handling non-constant strides. No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65363 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a04af4380d6814cb908d80ff8f52badc926a8bdc 22-Feb-2009 Dan Gohman <gohman@apple.com> Properly parenthesize this expression, fixing a real bug in the new
-full-lsr code, as well as a GCC warning.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65288 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3cd389de398e95b1633d310fc9c4af5b9f84b7af 22-Feb-2009 Evan Cheng <evan.cheng@apple.com> Only try to sink immediate when TLI is not null. It needs to check if immediate would fit in target addressing field.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65268 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d9fb7124035d6f95fb08c5157ab1813fbb2a282f 21-Feb-2009 Evan Cheng <evan.cheng@apple.com> Teach LSR sink to sink the immediate portion of the common expression back into uses if they fit in address modes of all the uses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65215 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d33cec18a9c0d9382dbf1e2b629f3daef29226ee 20-Feb-2009 Evan Cheng <evan.cheng@apple.com> Fix strange logic in CollectIVUsers used to determine whether all uses are
addresses, part 1. This fixes an obvious logic bug. Previously if the only
in-loop use is a PHI, it would return AllUsesAreAddresses as true.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65178 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ff518c86f7daf4e7abeabb3b03a5a9237c042da9 20-Feb-2009 Dan Gohman <gohman@apple.com> Simplify code and reduce indentation. No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65167 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6b38e29f13cb8700146e4b170567e2828553db9a 20-Feb-2009 Dan Gohman <gohman@apple.com> Fix 80-column violations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65159 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f0baa6e9cba77f54cee438e9a10e41c37789403e 20-Feb-2009 Dan Gohman <gohman@apple.com> It's not necessary to check if Base is null here.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65157 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
33e3a36f0a116b758708ef8fd0695d3a4cb21531 20-Feb-2009 Dan Gohman <gohman@apple.com> Add a comment about how Imm can be used for loop-variant values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65147 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c17e0cf6c03a36f424fafe88497b5fdf351cd50a 20-Feb-2009 Dan Gohman <gohman@apple.com> Implement "superhero" strength reduction, or full strength
reduction of address calculations down to basic pointer arithmetic.
This is currently off by default, as it needs a few other features
before it becomes generally useful. And even when enabled, full
strength reduction is only performed when it doesn't increase
register pressure, and when several other conditions are true.

This also factors out a bunch of exisiting LSR code out of
StrengthReduceStridedIVUsers into separate functions, and tidies
up IV insertion. This actually decreases register pressure even
in non-superhero mode. The change in iv-users-in-other-loops.ll
is an example of this; there are two more adds because there are
two fewer leas, and there is less spilling.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65108 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4a359ea2d5416706c3363687db9f03ed8daf635b 19-Feb-2009 Dan Gohman <gohman@apple.com> Use DEBUG() instead of passing *DOUT to WriteAsOperand,
since the latter just passes a null reference when
debugging is not enabled.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65060 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2f09f519542202b8af227c2a524f8fe82378a934 19-Feb-2009 Dan Gohman <gohman@apple.com> Make the debug output of LSR less cryptic and more informative.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65057 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f284ce203b656f1d6f933b67ad096a93d3cd7290 18-Feb-2009 Dan Gohman <gohman@apple.com> Fix a typo in a comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64859 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5a6c1a840ad343c0ed2fa54a0edb50b61f828f0f 17-Feb-2009 Evan Cheng <evan.cheng@apple.com> Strengthen the "non-constant stride must dominate loop preheader" check.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64703 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
8f40afe62db871230ac149de1c4ccc16ff48253a 15-Feb-2009 Evan Cheng <evan.cheng@apple.com> Fix pr3571: If stride is a value defined by an instruction, make sure it dominates the loop preheader. When IV users are strength reduced, the stride is inserted into the preheader. It could create a use before def situation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64579 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f8546f10c298fc4955ca1469e4843d3aebb6ab49 15-Feb-2009 Evan Cheng <evan.cheng@apple.com> ifdef out unneeded if statement.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64575 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e6986965691543d5415b98571801141b6a974984 13-Feb-2009 Dan Gohman <gohman@apple.com> Complete the sentance in this comment. I have reservations
about the code it describes, but at least now the comment
is right.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64465 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9194e8b0c827c97f396b209c7f4eeb75759e7068 13-Feb-2009 Dan Gohman <gohman@apple.com> Fix the code that checked if a SCEVAddRecExpr Start contains an
addrec in a different loop to check the value being added to
the accumulated Start value, not the Start value before it has
the new value added to it. This prevents LSR from going crazy
on the included testcase. Dale, please review.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64440 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
bc511725f08c45984be6ff47d069c3773a2f2eb0 13-Feb-2009 Dan Gohman <gohman@apple.com> Fix LSR's IV sorting function to explicitly sort by bitwidth
after sorting by stride value. This prevents it from missing
IV reuse opportunities in a host-sensitive manner.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64415 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1de17d574c0a4503f7dd6a4a3efce6f9353bf3c5 09-Feb-2009 Dale Johannesen <dalej@apple.com> Fix PR 3471, and some cleanups.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64177 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2f46bb8178e30e3b845859a44b57c048db06ef84 14-Jan-2009 Dale Johannesen <dalej@apple.com> Fix the time regression I introduced in 464.h264ref with
my earlier patch to this file.

The issue there was that all uses of an IV inside a loop
are actually references to Base[IV*2], and there was one
use outside that was the same but LSR didn't see the base
or the scaling because it didn't recurse into uses outside
the loop; thus, it used base+IV*scale mode inside the loop
instead of pulling base out of the loop. This was extra bad
because register pressure later forced both base and IV into
memory. Doing that recursion, at least enough
to figure out addressing modes, is a good idea in general;
the change in AddUsersIfInteresting does this. However,
there were side effects....

It is also possible for recursing outside the loop to
introduce another IV where there was only 1 before (if
the refs inside are not scaled and the ref outside is).
I don't think this is a common case, but it's in the testsuite.
It is right to be very aggressive about getting rid of
such introduced IVs (CheckForIVReuse and the handling of
nonzero RewriteFactor in StrengthReduceStridedIVUsers).
In the testcase in question the new IV produced this way
has both a nonconstant stride and a nonzero base, neither
of which was handled before. And when inserting
new code that feeds into a PHI, it's right to put such
code at the original location rather than in the PHI's
immediate predecessor(s) when the original location is outside
the loop (a case that couldn't happen before)
(RewriteInstructionToUseNewBase); better to avoid making
multiple copies of it in this case.

Also, the mechanism for keeping SCEV's corresponding to GEP's
no longer works, as the GEP might change after its SCEV
is remembered, invalidating the SCEV, and we might get a bad
SCEV value when looking up the GEP again for a later loop.
This also couldn't happen before, as we weren't recursing
into GEP's outside the loop.

Also, when we build an expression that involves a (possibly
non-affine) IV from a different loop as well as an IV from
the one we're interested in (containsAddRecFromDifferentLoop),
don't recurse into that. We can't do much with it and will
get in trouble if we try to create new non-affine IVs or something.

More testcases are coming.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62212 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ceb4d1aecb9deffe59b3dcdc9a783ffde8477be9 12-Jan-2009 Duncan Sands <baldrick@free.fr> Rename getABITypeSize to getTypePaddedSize, as
suggested by Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62099 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f6727b01a527369ecdbcf6ea0863dc776091f50c 24-Dec-2008 Dale Johannesen <dalej@apple.com> Revert 61362 and 61402 until SPEC breakage is fixed.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61403 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2fa25173244168208a51451b6c189adadbe2d085 24-Dec-2008 Dale Johannesen <dalej@apple.com> This fixes the bug in 175.vpr. It doesn't fix the
other SPEC breakage. I'll be reverting all recent
changes shortly, this checking is mostly so this
change doesn't get lost.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61402 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e6ec25543f05eff353fa6b55ed8d85e702b1dd31 23-Dec-2008 Dale Johannesen <dalej@apple.com> Fix the time regression I introduced in 464.h264ref with
my last patch to this file.

The issue there was that all uses of an IV inside a loop
are actually references to Base[IV*2], and there was one
use outside that was the same but LSR didn't see the base
or the scaling because it didn't recurse into uses outside
the loop; thus, it used base+IV*scale mode inside the loop
instead of pulling base out of the loop. This was extra bad
because register pressure later forced both base and IV into
memory. Doing that recursion, at least enough
to figure out addressing modes, is a good idea in general;
the change in AddUsersIfInteresting does this. However,
there were side effects....

It is also possible for recursing outside the loop to
introduce another IV where there was only 1 before (if
the refs inside are not scaled and the ref outside is).
I don't think this is a common case, but it's in the testsuite.
It is right to be very aggressive about getting rid of
such introduced IVs (CheckForIVReuse and the handling of
nonzero RewriteFactor in StrengthReduceStridedIVUsers).
In the testcase in question the new IV produced this way
has both a nonconstant stride and a nonzero base, neither
of which was handled before. And when inserting
new code that feeds into a PHI, it's right to put such
code at the original location rather than in the PHI's
immediate predecessor(s) when the original location is outside
the loop (a case that couldn't happen before)
(RewriteInstructionToUseNewBase); better to avoid making
multiple copies of it in this case.

Also, the mechanism for keeping SCEV's corresponding to GEP's
no longer works, as the GEP might change after its SCEV
is remembered, invalidating the SCEV, and we might get a bad
SCEV value when looking up the GEP again for a later loop.
This also couldn't happen before, as we weren't recursing
into GEP's outside the loop.

I owe some testcases for this, want to get it in for nightly runs.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61362 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a1d9cb1d4699c332baf47560292dd22b4e2d58ea 18-Dec-2008 Dale Johannesen <dalej@apple.com> Revert previous patch, appears to break bootstrap.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61181 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
12b882cf53cf6613a56e3c9165a98aa3ca93914a 18-Dec-2008 Dale Johannesen <dalej@apple.com> Fix the time regression I introduced in 464.h264ref with
my last patch to this file.

The issue there was that all uses of an IV inside a loop
are actually references to Base[IV*2], and there was one
use outside that was the same but LSR didn't see the base
or the scaling because it didn't recurse into uses outside
the loop; thus, it used base+IV*scale mode inside the loop
instead of pulling base out of the loop. This was extra bad
because register pressure later forced both base and IV into
memory. Doing that recursion, at least enough
to figure out addressing modes, is a good idea in general;
the change in AddUsersIfInteresting does this. However,
there were side effects....

It is also possible for recursing outside the loop to
introduce another IV where there was only 1 before (if
the refs inside are not scaled and the ref outside is).
I don't think this is a common case, but it's in the testsuite.
It is right to be very aggressive about getting rid of
such introduced IVs (CheckForIVReuse and the handling of
nonzero RewriteFactor in StrengthReduceStridedIVUsers).
In the testcase in question the new IV produced this way
has both a nonconstant stride and a nonzero base, neither
of which was handled before. (This patch does not handle
all the cases where this can happen.) And when inserting
new code that feeds into a PHI, it's right to put such
code at the original location rather than in the PHI's
immediate predecessor(s) when the original location is outside
the loop (a case that couldn't happen before)
(RewriteInstructionToUseNewBase); better to avoid making
multiple copies of it in this case.

Everything above is exercised in
CodeGen/X86/lsr-negative-stride.ll (and ifcvt4 in ARM which is
the same IR).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61178 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b0390620d462cc3f48492febdbdbae4cb45d8bcd 16-Dec-2008 Dale Johannesen <dalej@apple.com> Clarify that the scale factor from CheckForIVReuse
can be negative. Keep track of whether all uses of
an IV are outside the loop. Some cosmetics; no
functional change.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61109 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
46a879ebd384fb39cb680e4c3c182fefcdef5778 09-Dec-2008 Chris Lattner <sabre@nondot.org> Fix a really subtle off-by-one bug that Duncan noticed with valgrind
on test/CodeGen/Generic/2007-06-06-CriticalEdgeLandingPad.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60739 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
203af58aea3ae341d38e5c2c5b390b0c31d25557 05-Dec-2008 Dale Johannesen <dalej@apple.com> Make LoopStrengthReduce smarter about hoisting things out of
loops when they can be subsumed into addressing modes.

Change X86 addressing mode check to realize that
some PIC references need an extra register.
(I believe this is correct for Linux, if not, I'm sure
someone will tell me.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60608 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
308f24d4525a6365f8d65ba821786189c080c0ce 03-Dec-2008 Dale Johannesen <dalej@apple.com> Remove an unused field.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60508 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
544e0d0e52e68e8bb0c4ce18bd6584602353ce1c 03-Dec-2008 Dale Johannesen <dalej@apple.com> Fix a misspelled function name.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60506 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
67c79892949332568b082f124d9598971fa3277f 03-Dec-2008 Dale Johannesen <dalej@apple.com> Fix a really wrong comment.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60494 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
fb10cd490195128d4d36ed9d963f173a6d6ca46e 02-Dec-2008 Dale Johannesen <dalej@apple.com> Minor rewrite per review feedback.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60442 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
eccdd08d4c1a81ede221bbccf3045fe6f11e1003 02-Dec-2008 Dale Johannesen <dalej@apple.com> Make the code do what the comment says it does.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60431 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f8828eb41b2f8f0356ff6889c9924eade654e39a 02-Dec-2008 Chris Lattner <sabre@nondot.org> some random comment improvements.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60395 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
589bf0865ccd10d36f406d622c0160be249343e1 01-Dec-2008 Dale Johannesen <dalej@apple.com> Consider only references to an IV within the loop when
figuring out the base of the IV. This produces better
code in the example. (Addresses use (IV) instead of
(BASE,IV) - a significant improvement on low-register
machines like x86).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60374 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
99d0015735f8e2aee1a4b99e39ffdaadc8a1dba8 01-Dec-2008 Chris Lattner <sabre@nondot.org> Introduce a new array_pod_sort function and switch LSR to use it
instead of std::sort. This shrinks the release-asserts LSR.o file
by 1100 bytes of code on my system.

We should start using array_pod_sort where possible.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60335 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
09fb7dadf1f8f2efaae6a803c63fb29d06105df3 01-Dec-2008 Chris Lattner <sabre@nondot.org> Eliminate use of setvector for the DeadInsts set, just use a smallvector.
This is a lot cheaper and conceptually simpler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60332 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a68d4ca73e9cd0b19b2a48a2943e16cc0f89da27 01-Dec-2008 Chris Lattner <sabre@nondot.org> DeleteTriviallyDeadInstructions is always passed the
DeadInsts ivar, just use it directly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60330 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
bfcee36cd747bf9f791ba7aa3e9e8ac3671c6822 01-Dec-2008 Chris Lattner <sabre@nondot.org> simplify DeleteTriviallyDeadInstructions again, unlike my previous
buggy rewrite, this notifies ScalarEvolution of a pending instruction
about to be removed and then erases it, instead of erasing it then
notifying.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60329 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
411052bb96fb4a30035de6cafa492fa4f598e824 29-Nov-2008 Bill Wendling <isanbard@gmail.com> Temporarily revert r60195. It's causing an optimized bootstrap of llvm-gcc to fail.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60233 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1363949380374636974558813a19e79d01e63b7c 28-Nov-2008 Chris Lattner <sabre@nondot.org> Simplify LoopStrengthReduce::DeleteTriviallyDeadInstructions by
making it use RecursivelyDeleteTriviallyDeadInstructions to do
the heavy lifting.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60195 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a0d4486073f6303fbf33b50ac3fbae4601ea0229 28-Nov-2008 Chris Lattner <sabre@nondot.org> use continue to reduce indentation


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60192 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
394f0441e06dafca29f0752cf400990a5b8fe4b1 23-Oct-2008 Daniel Dunbar <daniel@zuster.org> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
586b7b75479990475ed5a03fae72d44e0b5ca8e7 01-Oct-2008 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ad7321f58a485ae80fe3da1f400aa695e250b1a8 15-Sep-2008 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4b3f08bac7def05de67f5c0e9f15c53d0870c7c1 09-Sep-2008 Devang Patel <dpatel@apple.com> fix overflow check.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56011 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
245d0ab166219708b511f04519d9e65d46a3df23 08-Sep-2008 Devang Patel <dpatel@apple.com> Remove unused counter.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55924 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
175f9d94db934dbd7630b95b6ca08d1f3e52e1fe 08-Sep-2008 Devang Patel <dpatel@apple.com> Remove OptimizeIVType()


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55913 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ae73dc1448d25b02cabc7c64c86c64371453dda8 04-Sep-2008 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e925ccc553e95cf348455b4ba1dca1fd5981f5bb 03-Sep-2008 Devang Patel <dpatel@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a9348dc7acc6f292425721c178311d7b0b5144b6 03-Sep-2008 Devang Patel <dpatel@apple.com> Check iteration count.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55680 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c72139134cbd5be74e443ca632209d39df45cb78 03-Sep-2008 Devang Patel <dpatel@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
108f92e376fd5f7c7c5c4e22dd10c1a5b279b1e3 03-Sep-2008 Devang Patel <dpatel@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
18bb2788a0edc0ec1c373465429743892c8d5fbe 27-Aug-2008 Devang Patel <dpatel@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
541532724e29203e28c2fe0136cf6eabd49d4532 27-Aug-2008 Devang Patel <dpatel@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a0b3909d432e9f2c79aee8ec3133f9b9ec71dc1a 26-Aug-2008 Devang Patel <dpatel@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ee2aa85f444d81395c15b63f6e361721536f7df6 17-Aug-2008 Evan Cheng <evan.cheng@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
35115f92e4a1e19921af4ae43db6e31f9a633738 15-Aug-2008 Devang Patel <dpatel@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
21066541ae22608106fa980bd90f9f6cc7cc8037 15-Aug-2008 Evan Cheng <evan.cheng@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
79ceb4463efc699c8aa1647d4ecbc15bed19e1c9 14-Aug-2008 Devang Patel <dpatel@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c677de2713646ab6d8200cd71613f6b4ae9885fb 13-Aug-2008 Devang Patel <dpatel@apple.com> Rename. s/FindIVForUser/FindIVUserForCond/g


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54754 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d16aba22c9eca0b2576a5fe5507f3c8ab378942e 13-Aug-2008 Devang Patel <dpatel@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f5e25f32c7605569390f5e81ebb582c96d74a1d2 06-Aug-2008 Evan Cheng <evan.cheng@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7375fbcbf261527638a08d80c8152778558c29d8 21-Jul-2008 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3fea643fb427e72907b7a40e940d7949d1d57e76 14-Jul-2008 Dan Gohman <gohman@apple.com> Fix uninitialized use of the Changed variable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53564 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1ce75dcbbcb6a67904a23b4ec701d1e994767c7e 07-Jul-2008 Evan Cheng <evan.cheng@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
73b43b9b549a75fb0015c825df68abd95705a67c 24-Jun-2008 Dan Gohman <gohman@apple.com> Fix spelling and grammar in a comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52648 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
cbfe5bbe88f5f2ee03a388585112f7609c8151ad 22-Jun-2008 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
cfeb6a450632f2a6cd05302633c8c2b8c90cfdfd 18-Jun-2008 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9b93dd1f1ab3532a101a432d7000477adfe6401d 17-Jun-2008 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
72b7b098c7ccac55e1dfc19a4c144bf5d8d30929 16-Jun-2008 Evan Cheng <evan.cheng@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
69d5053f9cef7de0a14d8d85d6738f24de2ef17e 16-Jun-2008 Evan Cheng <evan.cheng@apple.com> Iterating over SmallPtrSet is not deterministic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52339 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e562b1725ee068ff525082d1e9ba885c8928c72e 13-Jun-2008 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
6725cb5f1c1b59cbd71dc221623c7b4cabafafd0 11-Jun-2008 Gabor Greif <ggreif@gmail.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3cc8f9bfefb10dd361b903b0be89751d17aa15ef 24-May-2008 Evan Cheng <evan.cheng@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
010ee2d95516fe13a574bce5d682a8f8997ab60b 21-May-2008 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ca756ae886f1d39053ffd049123fdcc7e5c2aed3 20-May-2008 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f20d70d57e1723d70b48b3f19868e17b9282bbfc 16-May-2008 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
844731a7f1909f55935e3514c9e713a62d67662e 13-May-2008 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4a9a3e53746e3cc752d8a242ddc887a106cf5021 14-Apr-2008 Dan Gohman <gohman@apple.com> Minor whitespace and comment cleanups.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49671 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
051a950000e21935165db56695e35bade668193b 06-Apr-2008 Gabor Greif <ggreif@gmail.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
55e641b766a18878b51551d626d5a566102e487e 19-Mar-2008 Evan Cheng <evan.cheng@apple.com> Remove dead options.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48556 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
303595942502f17c087fa28874c2b89117148c45 29-Jan-2008 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4ee451de366474b9c228b4e5fa573795a715216d 29-Dec-2007 Chris Lattner <sabre@nondot.org> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
32e4c7c486084cdbed07925be4a0e9f3ab6caede 20-Dec-2007 Evan Cheng <evan.cheng@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d6b62a572210aff965a55626cf36a68821838844 20-Dec-2007 Evan Cheng <evan.cheng@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b51b4b5fdfdd7a85ea66776d7900214f8b24f826 17-Nov-2007 Dale Johannesen <dalej@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0e0014d0499d6ec6402e07b71cf24af992a9d297 31-Oct-2007 Evan Cheng <evan.cheng@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
8392772727ed9105c92fe4514d53dab74c333edc 30-Oct-2007 Evan Cheng <evan.cheng@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
af62c09437675369afcc481e88ed9cd5806491fe 29-Oct-2007 Evan Cheng <evan.cheng@apple.com> - 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9330c3af45453d0a3dd9caef40910a9a053e4de5 29-Oct-2007 Dan Gohman <gohman@apple.com> 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
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
8480bc5b5b0d75c2cfa08d71c29dc98c20e5882c 29-Oct-2007 Dan Gohman <gohman@apple.com> Remove an unused function argument.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43462 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b66cf43ef41e2e6de7cbe13c7d77de3f8efa0588 29-Oct-2007 Dan Gohman <gohman@apple.com> Fix a typo in a comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43461 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
aa34331e7832dc1139231626516e9587eeecb0ce 29-Oct-2007 Dan Gohman <gohman@apple.com> Avoid calling ValidStride when not all uses are addresses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43460 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
168a66b21e71e4c3301c9d4152d4c683a4bef889 27-Oct-2007 Evan Cheng <evan.cheng@apple.com> A number of LSR fixes:
- ChangeCompareStride only reuse stride that is larger than current stride. It
will let the general reuse mechanism to try to reuse a smaller stride.
- Watch out for multiplication overflow in ChangeCompareStride.
- Replace std::set with SmallPtrSet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43408 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f1fc54f9516b1a6729bfaf70c543aa61b1b15123 26-Oct-2007 Evan Cheng <evan.cheng@apple.com> Fix a crash. Make sure TLI is not null.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43384 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2bd122c4d934a70e031dc0ca5171719bac66c2c9 26-Oct-2007 Evan Cheng <evan.cheng@apple.com> Loosen up iv reuse to allow reuse of the same stride but a larger type when truncating from the larger type to smaller type is free.
e.g.
Turns this loop:
LBB1_1: # entry.bb_crit_edge
xorl %ecx, %ecx
xorw %dx, %dx
movw %dx, %si
LBB1_2: # bb
movl L_X$non_lazy_ptr, %edi
movw %si, (%edi)
movl L_Y$non_lazy_ptr, %edi
movw %dx, (%edi)
addw $4, %dx
incw %si
incl %ecx
cmpl %eax, %ecx
jne LBB1_2 # bb

into

LBB1_1: # entry.bb_crit_edge
xorl %ecx, %ecx
xorw %dx, %dx
LBB1_2: # bb
movl L_X$non_lazy_ptr, %esi
movw %cx, (%esi)
movl L_Y$non_lazy_ptr, %esi
movw %dx, (%esi)
addw $4, %dx
incl %ecx
cmpl %eax, %ecx
jne LBB1_2 # bb


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43375 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5f8ebaa5c0c216b7dbb16b781895e4af36bfa39a 26-Oct-2007 Evan Cheng <evan.cheng@apple.com> Do not rewrite compare instruction using iv of a different stride if the new
stride may be rewritten using the stride of the compare instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43367 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2c8ca5c415b876ef816286202621b1cf2c30fcad 25-Oct-2007 Evan Cheng <evan.cheng@apple.com> Remove code that's commented out.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43356 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
cdf43b1fadac74ecf1cc858e72bde877a10ceca1 25-Oct-2007 Evan Cheng <evan.cheng@apple.com> If a loop termination compare instruction is the only use of its stride,
and the compaison is against a constant value, try eliminate the stride
by moving the compare instruction to another stride and change its
constant operand accordingly. e.g.

loop:
...
v1 = v1 + 3
v2 = v2 + 1
if (v2 < 10) goto loop
=>
loop:
...
v1 = v1 + 3
if (v1 < 30) goto loop


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43336 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
02e4fa7d5fb4edd2ce9c7ede29c74d50cb126d7d 22-Oct-2007 Dan Gohman <gohman@apple.com> Strength reduction improvements.

- Avoid attempting stride-reuse in the case that there are users that
aren't addresses. In that case, there will be places where the
multiplications won't be folded away, so it's better to try to
strength-reduce them.

- Several SSE intrinsics have operands that strength-reduction can
treat as addresses. The previous item makes this more visible, as
any non-address use of an IV can inhibit stride-reuse.

- Make ValidStride aware of whether there's likely to be a base
register in the address computation. This prevents it from thinking
that things like stride 9 are valid on x86 when the base register is
already occupied.

Also, XFAIL the 2007-08-10-LEA16Use32.ll test; the new logic to avoid
stride-reuse elimintes the LEA in the loop, so the test is no longer
testing what it was intended to test.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43231 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
246b2564d3bbbafe06ebf6a67745cd24141b5cb4 22-Oct-2007 Dan Gohman <gohman@apple.com> Move the SCEV object factors from being static members of the individual
SCEV subclasses to being non-static member functions of the ScalarEvolution
class.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43224 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a7ac2bd4076096bb3a9986dd5a44f20c7f715518 02-Oct-2007 Dale Johannesen <dalej@apple.com> Fix stride computations for long double arrays.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42508 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
684b22df79c51114a12289e10a4063d5f02259a9 02-Aug-2007 Chris Lattner <sabre@nondot.org> wrap some long lines. Major offenders that are left include
gvn, gvnpre, dse, and predsimplify. To see these, use:

make check-line-length



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40738 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c2bbfc18e9adbbdcf5b3375d8d25e2452f7df7f1 01-Aug-2007 Dan Gohman <gohman@apple.com> More explicit keywords.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40673 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a9cfed77b6bc4930ffb07cbd2877cef5c44d93b2 31-Jul-2007 Dan Gohman <gohman@apple.com> Use SCEVExpander::InsertCastOfTo instead of calling new IntToPtrInst
directly, because the insert point used by the SCEVExpander may vary
from what LSR originally computes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40641 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5cec4db6ae13a41d04d86f37e347fc5b5997c948 19-Jun-2007 Dan Gohman <gohman@apple.com> Rename ScalarEvolution::deleteInstructionFromRecords to
deleteValueFromRecords and loosen the types to all it to accept
Value* instead of just Instruction*, since this is what
ScalarEvolution uses internally anyway. This allows more flexibility
for future uses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37657 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d19534add90a2a894af61523b830887097bb780b 15-Jun-2007 Dan Gohman <gohman@apple.com> Add a SCEV class and supporting code for sign-extend expressions.

This created an ambiguity for expandInTy to decide when to use
sign-extension or zero-extension, but it turns out that most of its callers
don't actually need a type conversion, now that LLVM types don't have
explicit signedness. Drop expandInTy in favor of plain expand, and change
the few places that actually need a type conversion to do it themselves.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37591 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b7d9dfc7ba4ae1ae9482eee62b1912b40dc64f42 07-Jun-2007 Devang Patel <dpatel@apple.com> Use DominatorTree instead of ETForest.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37499 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b47f6124f4893c00573d1a5be56a6e4cf877faeb 06-Jun-2007 Chris Lattner <sabre@nondot.org> Fix PR1495 and CodeGen/X86/2007-06-05-LSR-Dominator.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37454 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
fb3e1190fc33c93a7185695051d5aeeaddbae0ad 19-May-2007 Chris Lattner <sabre@nondot.org> Handle negative strides much more optimally. This compiles X86/lsr-negative-stride.ll
into:

_t:
movl 8(%esp), %ecx
movl 4(%esp), %eax
cmpl %ecx, %eax
je LBB1_3 #bb17
LBB1_1: #bb
cmpl %ecx, %eax
jg LBB1_4 #cond_true
LBB1_2: #cond_false
subl %eax, %ecx
cmpl %ecx, %eax
jne LBB1_1 #bb
LBB1_3: #bb17
ret
LBB1_4: #cond_true
subl %ecx, %eax
cmpl %ecx, %eax
jne LBB1_1 #bb
jmp LBB1_3 #bb17

instead of:

_t:
subl $4, %esp
movl %esi, (%esp)
movl 12(%esp), %ecx
movl 8(%esp), %eax
cmpl %ecx, %eax
je LBB1_4 #bb17
LBB1_1: #bb.outer
movl %ecx, %edx
negl %edx
LBB1_2: #bb
cmpl %ecx, %eax
jle LBB1_5 #cond_false
LBB1_3: #cond_true
addl %edx, %eax
cmpl %ecx, %eax
jne LBB1_2 #bb
LBB1_4: #bb17
movl (%esp), %esi
addl $4, %esp
ret
LBB1_5: #cond_false
movl %ecx, %edx
subl %eax, %edx
movl %eax, %esi
addl %esi, %esi
cmpl %ecx, %esi
je LBB1_4 #bb17
LBB1_6: #cond_false.bb.outer_crit_edge
movl %edx, %ecx
jmp LBB1_1 #bb.outer


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37252 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7d8ed8a94118ace05962e88689a4089c2f49366d 12-May-2007 Chris Lattner <sabre@nondot.org> significantly improve debug output of lsr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36996 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e5b01bea7b9b7dce7c24484d2d915b0c118d4d07 04-May-2007 Dan Gohman <gohman@apple.com> Use IntrinsicInst to test for prefetch instructions, which is ever so
slightly nicer than using CallInst with an extra check; thanks Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36743 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2acc7601650654d03cd53faeece8d7685a203105 04-May-2007 Dan Gohman <gohman@apple.com> Allow strength reduction to make use of addressing modes for the
address operand in a prefetch intrinsic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36713 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1997473cf72957d0e70322e2fe6fe2ab141c58a6 03-May-2007 Devang Patel <dpatel@apple.com> Drop 'const'


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36662 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3e15bf33e024b9df9e89351a165acfdb1dde51ed 02-May-2007 Devang Patel <dpatel@apple.com> Use 'static const char' instead of 'static const int'.
Due to darwin gcc bug, one version of darwin linker coalesces
static const int, which defauts PassID based pass identification.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36652 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
794fd75c67a2cdc128d67342c6d88a504d186896 01-May-2007 Devang Patel <dpatel@apple.com> Do not use typeinfo to identify pass in pass manager.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36632 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2a5fa189972c1ecc29f3682a732d15f94b9498f1 24-Apr-2007 Devang Patel <dpatel@apple.com> Fix
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070423/048333.html


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36380 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3dc6776b338f81e2d47daa42cc12c9f91053043d 15-Apr-2007 Owen Anderson <resistor@mac.com> Remove ImmediateDominator analysis. The same information can be obtained from DomTree. A lot of code for
constructing ImmediateDominator is now folded into DomTree construction.

This is part of the ongoing work for PR217.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36063 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c5494af8a90f398046c45bc2b7549ab9004c01d9 13-Apr-2007 Chris Lattner <sabre@nondot.org> Now that codegen prepare isn't defeating me, I can finally fix what I set
out to do! :)

This fixes a problem where LSR would insert a bunch of code into each MBB
that uses a particular subexpression (e.g. IV+base+C). The problem is that
this code cannot be CSE'd back together if inserted into different blocks.

This patch changes LSR to attempt to insert a single copy of this code and
share it, allowing codegenprepare to duplicate the code if it can be sunk
into various addressing modes. On CodeGen/ARM/lsr-code-insertion.ll,
for example, this gives us code like:

add r8, r0, r5
str r6, [r8, #+4]
..
ble LBB1_4 @cond_next
LBB1_3: @cond_true
str r10, [r8, #+4]
LBB1_4: @cond_next
...
LBB1_5: @cond_true55
ldr r6, LCPI1_1
str r6, [r8, #+4]

instead of:

add r10, r0, r6
str r8, [r10, #+4]
...
ble LBB1_4 @cond_next
LBB1_3: @cond_true
add r8, r0, r6
str r10, [r8, #+4]
LBB1_4: @cond_next
...
LBB1_5: @cond_true55
add r8, r0, r6
ldr r10, LCPI1_1
str r10, [r8, #+4]

Besides being smaller and more efficient, this makes it immediately
obvious that it is profitable to predicate LBB1_3 now :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35972 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
579633cd1006f6add1b022e9c2bc96f7f0e65777 10-Apr-2007 Chris Lattner <sabre@nondot.org> switch LSR to use isLegalAddressingMode instead of other simpler hooks


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35837 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ba43963e96c9eb28d4f6862e46c5d3fbdc1f3b96 07-Apr-2007 Owen Anderson <resistor@mac.com> Completely purge DomSet. This is the (hopefully) final patch for PR1171.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35731 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
aed01d19315132daf68414ace410ec725b4b6d30 03-Apr-2007 Chris Lattner <sabre@nondot.org> split some code out into a helper function


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35615 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1d31290634eccc3b360c427282d59780d76b9169 03-Apr-2007 Chris Lattner <sabre@nondot.org> allow -1 strides to reuse "1" strides.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35607 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1ebd89eb6b4f5df8d8171ee654a73ecdf3f66580 02-Apr-2007 Chris Lattner <sabre@nondot.org> Pass the type of the store access, not the type of the store, into the
target hook. This allows us to codegen a loop as:

LBB1_1: @cond_next
mov r2, #0
str r2, [r0, +r3, lsl #2]
add r3, r3, #1
cmn r3, #1
bne LBB1_1 @cond_next

instead of:

LBB1_1: @cond_next
mov r2, #0
str r2, [r0], #+4
add r3, r3, #1
cmn r3, #1
bne LBB1_1 @cond_next

This looks the same, but has one fewer induction variable (and therefore,
one fewer register) live in the loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35592 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
fe35555d09ecdad4b42da1138a1d40ea4b83898e 02-Apr-2007 Chris Lattner <sabre@nondot.org> print the type of an inserted IV in -debug mode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35563 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
da91f49751b9b55a41d315b9fbdbb14614587b03 26-Mar-2007 Dale Johannesen <dalej@apple.com> Look through bitcast when finding IVs. (Chris' patch really.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35347 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
8e59e163db8cd3e7b4c96e438fbedf78bff06707 20-Mar-2007 Dale Johannesen <dalej@apple.com> do not share old induction variables when this would result in invalid
instructions (that would have to be split later)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35227 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c01a53007a4f4f9a601f1cc83ff4e2935405b905 20-Mar-2007 Jeff Cohen <jeffc@jolt-lang.org> Fix some VC++ warnings.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35224 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
dc42f48ea90132509e678028e7dbab5544ef0794 20-Mar-2007 Dale Johannesen <dalej@apple.com> use types of loads and stores, not address, in CheckForIVReuse


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35197 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1d95816db537242b3ba0e43a0ec96342ad696bf2 13-Mar-2007 Evan Cheng <evan.cheng@apple.com> Correct type info for isLegalAddressImmediate() check.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35086 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5eef2d21a0c1cc4560a49e4dcdec9c00946a86c2 13-Mar-2007 Evan Cheng <evan.cheng@apple.com> Use new TargetLowering addressing modes hooks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35072 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4fe26582c09ec19873753cb4e9bb2ac3cdace88a 09-Mar-2007 Devang Patel <dpatel@apple.com> Increment iterator now because IVUseShouldUsePostIncValue may remove
User from the list of I users.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35051 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0f54dcbf07c69e41ecaa6b4fbf0d94956d8e9ff5 06-Mar-2007 Devang Patel <dpatel@apple.com> Now LoopStrengthReduce is a LoopPass.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34984 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
bee0f663d842f5aa41286c22815446e2d22de95a 03-Mar-2007 Reid Spencer <rspencer@reidspencer.com> Finally get this patch right :)
Replace expensive getZExtValue() == 0 calls with isZero() calls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34861 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
502db93a8ab376730164db43ca3ce8032b72bd59 03-Mar-2007 Reid Spencer <rspencer@reidspencer.com> Dang, I've done that twice now! Undo previous commit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34860 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a5dae0cac062a53edb2fc2dcd5be7658388d025a 03-Mar-2007 Reid Spencer <rspencer@reidspencer.com> Use more efficient test for one value in a ConstantInt.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34859 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
513d0f25ed9b719841c4c9f18e0f22e2ffd426b4 02-Mar-2007 Reid Spencer <rspencer@reidspencer.com> Reverse a premature commital.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34822 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
cae5754619433aed7be74abbf1c0551a82d369cb 02-Mar-2007 Reid Spencer <rspencer@reidspencer.com> Prefer non-virtual calls to ConstantInt::isZero over virtual calls to
Constant::isNullValue() in situations where it is possible.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34821 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b1919e2f08ecb37140af676fd2916f8d5ed7df3d 10-Feb-2007 Chris Lattner <sabre@nondot.org> Privatize StructLayout::MemberOffsets, adding an accessor


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34156 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9133fe28954d498fc4de13064c7d65bd811de02c 06-Feb-2007 Reid Spencer <rspencer@reidspencer.com> Apply the VISIBILITY_HIDDEN field to the remaining anonymous classes in
the Transforms library. This reduces debug library size by 132 KB, debug
binary size by 376 KB, and reduces link time for llvm tools slightly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33939 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
42a75517250017a52afb03a0ade03cbd49559fe5 15-Jan-2007 Chris Lattner <sabre@nondot.org> rename Type::isIntegral to Type::isInteger, eliminating the old Type::isInteger.
rename Type::getIntegralTypeMask to Type::getIntegerTypeMask.

This makes naming much more consistent. For example, there are now no longer any
instances of IntegerType that are not considered isInteger! :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33225 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4d5f508318b2f666ed50a2ed5e49e4aa343a92d6 15-Jan-2007 Chris Lattner <sabre@nondot.org> Eliminate calls to isInteger, generalizing code and tightening checks as needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33218 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ac8cdf79e7b08c5a5be8efab7750835d5a57b2bc 08-Jan-2007 Reid Spencer <rspencer@reidspencer.com> For PR1097:
Enable complex addressing modes on 64-bit platforms involving two induction
variables by keeping a size and scale in 64-bits not 32.
Patch by Dan Gohman.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33011 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d5dc0fb011af11c2ca4b5f42852dd51830b0fdee 06-Jan-2007 Chris Lattner <sabre@nondot.org> no need to worry about int vs uint any more.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32946 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c5b206b6be61d0d933b98b6af5e22f42edd48ad1 31-Dec-2006 Reid Spencer <rspencer@reidspencer.com> For PR950:
This patch replaces signed integer types with signless ones:
1. [US]Byte -> Int8
2. [U]Short -> Int16
3. [U]Int -> Int32
4. [U]Long -> Int64.
5. Removal of isSigned, isUnsigned, getSignedVersion, getUnsignedVersion
and other methods related to signedness. In a few places this warranted
identifying the signedness information from other sources.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32785 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e4d87aa2de6e52952dca73716386db09aad5a8fd 23-Dec-2006 Reid Spencer <rspencer@reidspencer.com> For PR950:
This patch removes the SetCC instructions and replaces them with the ICmp
and FCmp instructions. The SetCondInst instruction has been removed and
been replaced with ICmpInst and FCmpInst.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32751 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0e5f499638c8d277b9dc4a4385712177c53b5681 19-Dec-2006 Chris Lattner <sabre@nondot.org> Switch over Transforms/Scalar to use the STATISTIC macro. For each statistic
converted, we lose a static initializer. This also allows GCC to emit warnings
about unused statistics.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32690 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3ba68b9eef2851dae8a9d1b18928c6fa2e3c5f87 13-Dec-2006 Reid Spencer <rspencer@reidspencer.com> Change the interface to SCEVExpander::InsertCastOfTo to take a cast opcode
so the decision of which opcode to use is pushed upward to the caller.
Adjust the callers to pass the expected opcode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32535 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4da49122f3f3c8da68a52723d846b88c72166a68 12-Dec-2006 Reid Spencer <rspencer@reidspencer.com> Change inferred getCast into specific getCast. Passes all tests.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32469 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e81561909d128c6e2d8033cb5465a49b2596b26a 07-Dec-2006 Bill Wendling <isanbard@gmail.com> Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are
now cerr, cout, and NullStream resp.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32298 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ac0b6ae358944ae8b2b5a11dc08f52c3ed89f2da 06-Dec-2006 Chris Lattner <sabre@nondot.org> Detemplatize the Statistic class. The only type it is instantiated with
is 'unsigned'.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32279 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3da59db637a887474c1b1346c1f3ccf53b6c4663 27-Nov-2006 Reid Spencer <rspencer@reidspencer.com> For PR950:
The long awaited CAST patch. This introduces 12 new instructions into LLVM
to replace the cast instruction. Corresponding changes throughout LLVM are
provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the
exception of 175.vpr which fails only on a slight floating point output
difference.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31931 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b7427031372337e6d67f9573ec6c722ab5ea913e 26-Nov-2006 Bill Wendling <isanbard@gmail.com> Removed #include <iostream> and replaced with llvm_* streams.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31923 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
020f714a93fb13e1e6c26d77938062abbb9728f0 17-Nov-2006 Chris Lattner <sabre@nondot.org> If an indvar with a variable stride is used by the exit condition, go ahead
and handle it like constant stride vars. This fixes some bad codegen in
variable stride cases. For example, it compiles this:

void foo(int k, int i) {
for (k=i+i; k <= 8192; k+=i)
flags2[k] = 0;
}

to:

LBB1_1: #bb.preheader
movl %eax, %ecx
addl %ecx, %ecx
movl L_flags2$non_lazy_ptr, %edx
LBB1_2: #bb
movb $0, (%edx,%ecx)
addl %eax, %ecx
cmpl $8192, %ecx
jle LBB1_2 #bb
LBB1_5: #return
ret

or (if the array is local and we are in dynamic-nonpic or static mode):

LBB3_2: #bb
movb $0, _flags2(%ecx)
addl %eax, %ecx
cmpl $8192, %ecx
jle LBB3_2 #bb

and:

lis r2, ha16(L_flags2$non_lazy_ptr)
lwz r2, lo16(L_flags2$non_lazy_ptr)(r2)
slwi r3, r4, 1
LBB1_2: ;bb
li r5, 0
add r6, r4, r3
stbx r5, r2, r3
cmpwi cr0, r6, 8192
bgt cr0, LBB1_5 ;return

instead of:

leal (%eax,%eax,2), %ecx
movl %eax, %edx
addl %edx, %edx
addl L_flags2$non_lazy_ptr, %edx
xorl %esi, %esi
LBB1_2: #bb
movb $0, (%edx,%esi)
movl %eax, %edi
addl %esi, %edi
addl %ecx, %esi
cmpl $8192, %esi
jg LBB1_5 #return

and:

lis r2, ha16(L_flags2$non_lazy_ptr)
lwz r2, lo16(L_flags2$non_lazy_ptr)(r2)
mulli r3, r4, 3
slwi r5, r4, 1
li r6, 0
add r2, r2, r5
LBB1_2: ;bb
li r5, 0
add r7, r3, r6
stbx r5, r2, r6
add r6, r4, r6
cmpwi cr0, r7, 8192
ble cr0, LBB1_2 ;bb

This speeds up Benchmarks/Shootout/sieve from 8.533s to 6.464s and
implements LoopStrengthReduce/var_stride_used_by_compare.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31809 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3ed469ccd7b028a030b550d84b7336d146f5d8fa 02-Nov-2006 Reid Spencer <rspencer@reidspencer.com> For PR786:
Turn on -Wunused and -Wno-unused-parameter. Clean up most of the resulting
fall out by removing unused variables. Remaining warnings have to do with
unused functions (I didn't want to delete code without review) and unused
variables in generated code. Maintainers should clean up the remaining
issues when they see them. All changes pass DejaGnu tests and Olden.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31380 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0997fadc3781c3f7e9386ec0f232aaba795f14e3 28-Oct-2006 Chris Lattner <sabre@nondot.org> break edges more intelligently


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31257 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1b9c8e73b5d620cf2d9a8e150b179fe95ddb8c4e 28-Oct-2006 Chris Lattner <sabre@nondot.org> prepare for a change I'm about to make


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31248 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b83eb6447ba155342598f0fabe1f08f5baa9164a 20-Oct-2006 Reid Spencer <rspencer@reidspencer.com> For PR950:
This patch implements the first increment for the Signless Types feature.
All changes pertain to removing the ConstantSInt and ConstantUInt classes
in favor of just using ConstantInt.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31063 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7f8897f22e88271cfa114998a4d6088e7c8e8e11 28-Aug-2006 Chris Lattner <sabre@nondot.org> eliminate RegisterOpt. It does the same thing as RegisterPass.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29925 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a4f0b3a084d120cfc5b5bb06f64b222f5cb72740 27-Aug-2006 Chris Lattner <sabre@nondot.org> s|llvm/Support/Visibility.h|llvm/Support/Compiler.h|


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29911 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7e79b3898ddd919170d367a516f51296017146c2 03-Aug-2006 Chris Lattner <sabre@nondot.org> Changes:
1. Update an obsolete comment.
2. Make the sorting by base an explicit (though still N^2) step, so
that the code is more clear on what it is doing.
3. Partition uses so that uses inside the loop are handled before uses
outside the loop.

Note that none of these changes currently changes the code inserted by LSR,
but they are a stepping stone to getting there.

This code is the result of some crazy pair programming with Nate. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29493 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
31e773147bf13cb11c2bf343db5706fe3e2923d7 18-Jul-2006 Evan Cheng <evan.cheng@apple.com> Only reuse a previous IV if it would not require a type conversion.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29186 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9525528a7dc5462b6374d38c81ba5c07b11741fe 29-Jun-2006 Chris Lattner <sabre@nondot.org> Use hidden visibility to make symbols in an anonymous namespace get
dropped. This shrinks libllvmgcc.dylib another 67K


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28975 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
86c75d31133319a88216c1b1cd26a789e4023000 09-Jun-2006 Evan Cheng <evan.cheng@apple.com> RewriteExpr, either the new PHI node of induction variable or the
post-increment value, should be first cast to the appropriated type (to the
type of the common expr). Otherwise, the rewrite of a use based on (common +
iv) may end up with an incorrect type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28735 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ad2072643ac2ea2c13f991474e500b28a160bb46 12-Apr-2006 Reid Spencer <rspencer@reidspencer.com> Get rid of a signed/unsigned compare warning.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27625 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
98d9811db263ee040d9a6a69ef9e1c4fdc8c219d 24-Mar-2006 Chris Lattner <sabre@nondot.org> Fix spello


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27052 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
035c6a23564a0ff4384a67d6e20d258a6a2dac95 22-Mar-2006 Chris Lattner <sabre@nondot.org> silence a bogus gcc warning


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26953 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
21495775e710d37003e100862cdc647cbdc3b999 18-Mar-2006 Evan Cheng <evan.cheng@apple.com> - Fixed a bogus if condition.
- Added more debugging info.
- Allow reuse of IV of negative stride. e.g. -4 stride == 2 * iv of -2 stride.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26841 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4496a50deb95527508070eb649e9b56a02b588c3 18-Mar-2006 Evan Cheng <evan.cheng@apple.com> Sort StrideOrder so we can process the smallest strides first. This allows
for more IV reuses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26837 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
eb8f9e229740a0f292f5e8f0975bd10b7889b194 17-Mar-2006 Evan Cheng <evan.cheng@apple.com> Allow users of iv / stride to be rewritten with expression that is a multiply
of a smaller stride even if they have a common loop invariant expression part.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26828 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d1d6b5cce260808deeac0227b00f6f81a20b2c6f 16-Mar-2006 Evan Cheng <evan.cheng@apple.com> For each loop, keep track of all the IV expressions inserted indexed by
stride. For a set of uses of the IV of a stride which is a multiple
of another stride, do not insert a new IV expression. Rather, reuse the
previous IV and rewrite the uses as uses of IV expression multiplied by
the factor.

e.g.
x = 0 ...; x ++
y = 0 ...; y += 4
then use of y can be rewritten as use of 4*x for x86.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26803 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d277f2c66914aecb619c12855f6afae4c7ef883b 14-Mar-2006 Evan Cheng <evan.cheng@apple.com> Added target lowering hooks which LSR consults to make more intelligent
transformation decisions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26738 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0a70f219f45077dfaa7e37ad1ed6f760f1f7a1e8 04-Feb-2006 Chris Lattner <sabre@nondot.org> Use SCEVExpander::InsertCastOfTo instead of our own code. This reduces
#LLVM LOC, and auto-cse's cast instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25974 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
221fc3c6d69bd3854e9121f51e3283492c222ab7 04-Feb-2006 Chris Lattner <sabre@nondot.org> Fix two significant bugs in LSR:

1. When rewriting code in outer loops, sometimes we would insert code into
inner loops that is invariant in that loop.
2. Notice that 4*(2+x) is 8+4*x and use that to simplify expressions.

This is a performance neutral change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25964 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
dac58ad983c62b49629e1f2969f4e0a621167d63 23-Jan-2006 Chris Lattner <sabre@nondot.org> Make iostream #inclusion explicit


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25514 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
88cac3d2f70d01423f56363f24e172786428b3cf 11-Jan-2006 Chris Lattner <sabre@nondot.org> Switch these to using ETForest instead of DominatorSet to compute itself.
Patch written by Daniel Berlin!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25202 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e08dc62b1a3b72e351165128ba63c2cdd2f41eb6 05-Dec-2005 Chris Lattner <sabre@nondot.org> getRawValue zero extens for unsigned values, use getsextvalue so that we
know that small negative values fit into the immediate field of addressing
modes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24608 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
63ad7963e4fc68a418cc48e21ba175a2d7093ec9 21-Oct-2005 Chris Lattner <sabre@nondot.org> My previous patch was too conservative. Reject FP and void types, but do
allow pointer types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23859 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1e9f3af561932b324c45c05ff9a8728143e90753 20-Oct-2005 Chris Lattner <sabre@nondot.org> Do NOT touch FP ops with LSR. This fixes a testcase Nate sent me from an
inner loop like this:

LBB_RateConvertMono8AltiVec_2: ; no_exit
lis r2, ha16(.CPI_RateConvertMono8AltiVec_0)
lfs f3, lo16(.CPI_RateConvertMono8AltiVec_0)(r2)
fmr f3, f3
fadd f0, f2, f0
fadd f3, f0, f3
fcmpu cr0, f3, f1
bge cr0, LBB_RateConvertMono8AltiVec_2 ; no_exit

to an inner loop like this:

LBB_RateConvertMono8AltiVec_1: ; no_exit
fsub f2, f2, f1
fcmpu cr0, f2, f1
fmr f0, f2
bge cr0, LBB_RateConvertMono8AltiVec_1 ; no_exit

Doh! good catch!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23838 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d6155e96f78a9f4344f5e697f7dd74d2f2325092 11-Oct-2005 Chris Lattner <sabre@nondot.org> Fix (hopefully the last) issue where LSR is nondeterminstic. When pulling
out CSE's of base expressions it could build a result whose order was
nondet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23698 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7b445c521bc191d0d25799b289e17b45f202a1af 11-Oct-2005 Chris Lattner <sabre@nondot.org> Fix another problem where LSR was being nondeterminstic. Also remove elements
from the end of a vector instead of the beginning


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23697 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b4dd1b86fab8f5f60e06f54a7416c9d0f3e0016f 11-Oct-2005 Chris Lattner <sabre@nondot.org> Fix another lsr-is-nondeterministic case


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23695 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a18af06360f0559bb8caaed2b1c99715604c6d7d 09-Oct-2005 Chris Lattner <sabre@nondot.org> Hrm, you didn't see this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23673 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7305ae28df07e0b9c9a8a020a9f9596de25077aa 09-Oct-2005 Chris Lattner <sabre@nondot.org> Fix a source of non-determinism in the backend: the order of processing
IV strides dependend on the pointer order of the strides in memory.
Non-determinism is bad.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23672 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5e8ca66914fc9da9848cf6b1a29dd5075f4c721f 03-Oct-2005 Chris Lattner <sabre@nondot.org> Make IVUseShouldUsePostIncValue more aggressive when the use is a PHI. In
particular, it should realize that phi's use their values in the pred block
not the phi block itself. This change turns our em3d loop from this:

_test:
cmpwi cr0, r4, 0
bgt cr0, LBB_test_2 ; entry.no_exit_crit_edge
LBB_test_1: ; entry.loopexit_crit_edge
li r2, 0
b LBB_test_6 ; loopexit
LBB_test_2: ; entry.no_exit_crit_edge
li r6, 0
LBB_test_3: ; no_exit
or r2, r6, r6
lwz r6, 0(r3)
cmpw cr0, r6, r5
beq cr0, LBB_test_6 ; loopexit
LBB_test_4: ; endif
addi r3, r3, 4
addi r6, r2, 1
cmpw cr0, r6, r4
blt cr0, LBB_test_3 ; no_exit
LBB_test_5: ; endif.loopexit.loopexit_crit_edge
addi r3, r2, 1
blr
LBB_test_6: ; loopexit
or r3, r2, r2
blr

into:

_test:
cmpwi cr0, r4, 0
bgt cr0, LBB_test_2 ; entry.no_exit_crit_edge
LBB_test_1: ; entry.loopexit_crit_edge
li r2, 0
b LBB_test_5 ; loopexit
LBB_test_2: ; entry.no_exit_crit_edge
li r6, 0
LBB_test_3: ; no_exit
lwz r2, 0(r3)
cmpw cr0, r2, r5
or r2, r6, r6
beq cr0, LBB_test_5 ; loopexit
LBB_test_4: ; endif
addi r3, r3, 4
addi r6, r6, 1
cmpw cr0, r6, r4
or r2, r6, r6
blt cr0, LBB_test_3 ; no_exit
LBB_test_5: ; loopexit
or r3, r2, r2
blr


Unfortunately, this is actually worse code, because the register coallescer
is getting confused somehow. If it were doing its job right, it could turn the
code into this:

_test:
cmpwi cr0, r4, 0
bgt cr0, LBB_test_2 ; entry.no_exit_crit_edge
LBB_test_1: ; entry.loopexit_crit_edge
li r6, 0
b LBB_test_5 ; loopexit
LBB_test_2: ; entry.no_exit_crit_edge
li r6, 0
LBB_test_3: ; no_exit
lwz r2, 0(r3)
cmpw cr0, r2, r5
beq cr0, LBB_test_5 ; loopexit
LBB_test_4: ; endif
addi r3, r3, 4
addi r6, r6, 1
cmpw cr0, r6, r4
blt cr0, LBB_test_3 ; no_exit
LBB_test_5: ; loopexit
or r3, r6, r6
blr

... which I'll work on next. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23604 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0ae33eb243417982fbdca792460bdd986108ac09 03-Oct-2005 Chris Lattner <sabre@nondot.org> Refactor some code into a function


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23603 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1902ff4d82559f248082dec39f50628330bad275 03-Oct-2005 Chris Lattner <sabre@nondot.org> This break is bogus and I have no idea why it was there. Basically it prevents
memoizing code when IV's are used by phinodes outside of loops. In a simple
example, we were getting this code before (note that r6 and r7 are isomorphic
IV's):

li r6, 0
or r7, r6, r6
LBB_test_3: ; no_exit
lwz r2, 0(r3)
cmpw cr0, r2, r5
or r2, r7, r7
beq cr0, LBB_test_5 ; loopexit
LBB_test_4: ; endif
addi r2, r7, 1
addi r7, r7, 1
addi r3, r3, 4
addi r6, r6, 1
cmpw cr0, r6, r4
blt cr0, LBB_test_3 ; no_exit

Now we get:

li r6, 0
LBB_test_3: ; no_exit
or r2, r6, r6
lwz r6, 0(r3)
cmpw cr0, r6, r5
beq cr0, LBB_test_6 ; loopexit
LBB_test_4: ; endif
addi r3, r3, 4
addi r6, r2, 1
cmpw cr0, r6, r4
blt cr0, LBB_test_3 ; no_exit

this was noticed in em3d.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23602 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
37edbf0b21959e176672ae51f8b7e86ba1ef727d 03-Oct-2005 Chris Lattner <sabre@nondot.org> when checking if we should move a split edge block outside of a loop,
check the presplit pred, not the post-split pred. This was causing us
to make the wrong decision in some cases, leaving the critical edge block
in the loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23601 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
fe15830f962bb7fef046203a77d438d087772b34 27-Sep-2005 Chris Lattner <sabre@nondot.org> Make the pass name simpler


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23476 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
396b2baf3ca0ee46e696713d34943035206d7a46 13-Sep-2005 Chris Lattner <sabre@nondot.org> Fix an issue where LSR would miss rewriting a use of an IV expression by a PHI node that is not the original PHI.

This fixes up a dot-product loop in galgel, speeding it up from 18.47s to
16.13s.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23327 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
12b50410cd0a8cd81a7f528f862005e80921cf58 12-Sep-2005 Chris Lattner <sabre@nondot.org> Fix a regression from last night, which caused this pass to create invalid
code for IV uses outside of loops that are not dominated by the latch block.
We should only convert these uses to use the post-inc value if they ARE
dominated by the latch block.

Also use a new LoopInfo method to simplify some code.

This fixes Transforms/LoopStrengthReduce/2005-09-12-UsesOutOutsideOfLoop.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23318 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c6bae65b49f3b0bb457b6bdb60e29bd9a44e743a 12-Sep-2005 Chris Lattner <sabre@nondot.org> _test:
li r2, 0
LBB_test_1: ; no_exit.2
li r5, 0
stw r5, 0(r3)
addi r2, r2, 1
addi r3, r3, 4
cmpwi cr0, r2, 701
blt cr0, LBB_test_1 ; no_exit.2
LBB_test_2: ; loopexit.2.loopexit
addi r2, r2, 1
stw r2, 0(r4)
blr
[zion ~/llvm]$ cat > ~/xx
Uses of IV's outside of the loop should use hte post-incremented version
of the IV, not the preincremented version. This helps many loops (e.g. in sixtrack)
which used to generate code like this (this is the code from the
dont-hoist-simple-loop-constants.ll testcase):

_test:
li r2, 0 **** IV starts at 0
LBB_test_1: ; no_exit.2
or r5, r2, r2 **** Copy for loop exit
li r2, 0
stw r2, 0(r3)
addi r3, r3, 4
addi r2, r5, 1
addi r6, r5, 2 **** IV+2
cmpwi cr0, r6, 701
blt cr0, LBB_test_1 ; no_exit.2
LBB_test_2: ; loopexit.2.loopexit
addi r2, r5, 2 **** IV+2
stw r2, 0(r4)
blr

And now generated code like this:

_test:
li r2, 1 *** IV starts at 1
LBB_test_1: ; no_exit.2
li r5, 0
stw r5, 0(r3)
addi r2, r2, 1
addi r3, r3, 4
cmpwi cr0, r2, 701 *** IV.postinc + 0
blt cr0, LBB_test_1
LBB_test_2: ; loopexit.2.loopexit
stw r2, 0(r4) *** IV.postinc + 0
blr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23313 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7259df3ab862d378427cf96cd69d1bc69aa2e5cb 10-Sep-2005 Chris Lattner <sabre@nondot.org> implement Transforms/LoopStrengthReduce/dont-hoist-simple-loop-constants.ll.

We used to emit this code for it:

_test:
li r2, 1 ;; Value tying up a register for the whole loop
li r5, 0
LBB_test_1: ; no_exit.2
or r6, r5, r5
li r5, 0
stw r5, 0(r3)
addi r5, r6, 1
addi r3, r3, 4
add r7, r2, r5 ;; should be addi r7, r5, 1
cmpwi cr0, r7, 701
blt cr0, LBB_test_1 ; no_exit.2
LBB_test_2: ; loopexit.2.loopexit
addi r2, r6, 2
stw r2, 0(r4)
blr

now we emit this:

_test:
li r2, 0
LBB_test_1: ; no_exit.2
or r5, r2, r2
li r2, 0
stw r2, 0(r3)
addi r3, r3, 4
addi r2, r5, 1
addi r6, r5, 2 ;; whoa, fold those adds!
cmpwi cr0, r6, 701
blt cr0, LBB_test_1 ; no_exit.2
LBB_test_2: ; loopexit.2.loopexit
addi r2, r5, 2
stw r2, 0(r4)
blr

more improvement coming.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23306 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
8385e51e210fb5c1e7e48eae150b31679b3e137d 17-Aug-2005 Chris Lattner <sabre@nondot.org> Fix Transforms/LoopStrengthReduce/2005-08-17-OutOfLoopVariant.ll, a crash
on 177.mesa


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22843 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
aa96ae780afa5475e62df284855a971216289212 17-Aug-2005 Chris Lattner <sabre@nondot.org> Use a new helper to split critical edges, making the code simpler.

Do not claim to not change the CFG. We do change the cfg to split critical
edges. This isn't causing us a problem now, but could likely do so in the
future.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22824 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
80b32b3aab369534a25cfab6d9b7447cc4a8ff1d 16-Aug-2005 Chris Lattner <sabre@nondot.org> Fix a bad case in gzip where we put lots of things in registers across the
loop, because a IV-dependent value was used outside of the loop and didn't
have immediate-folding capability


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22798 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
27e5142309946ca12c633b265673af0c24684427 13-Aug-2005 Chris Lattner <sabre@nondot.org> Ooops, don't forget to clear this. The real inner loop is now:

.LBB_foo_3: ; no_exit.1
lfd f2, 0(r9)
lfd f3, 8(r9)
fmul f4, f1, f2
fmadd f4, f0, f3, f4
stfd f4, 8(r9)
fmul f3, f1, f3
fmsub f2, f0, f2, f3
stfd f2, 0(r9)
addi r9, r9, 16
addi r8, r8, 1
cmpw cr0, r8, r4
ble .LBB_foo_3 ; no_exit.1


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22782 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
934520a747722ecf94f35768e5b88eeaf44c3b24 13-Aug-2005 Chris Lattner <sabre@nondot.org> Recursively scan scev expressions for common subexpressions. This allows us
to handle nested loops much better, for example, by being able to tell that
these two expressions:

{( 8 + ( 16 * ( 1 + %Tmp11 + %Tmp12)) + %c_),+,( 16 * %Tmp 12)}<loopentry.1>

{(( 16 * ( 1 + %Tmp11 + %Tmp12)) + %c_),+,( 16 * %Tmp12)}<loopentry.1>

Have the following common part that can be shared:
{(( 16 * ( 1 + %Tmp11 + %Tmp12)) + %c_),+,( 16 * %Tmp12)}<loopentry.1>

This allows us to codegen an important inner loop in 168.wupwise as:

.LBB_foo_4: ; no_exit.1
lfd f2, 16(r9)
fmul f3, f0, f2
fmul f2, f1, f2
fadd f4, f3, f2
stfd f4, 8(r9)
fsub f2, f3, f2
stfd f2, 16(r9)
addi r8, r8, 1
addi r9, r9, 16
cmpw cr0, r8, r4
ble .LBB_foo_4 ; no_exit.1

instead of:

.LBB_foo_3: ; no_exit.1
lfdx f2, r6, r9
add r10, r6, r9
lfd f3, 8(r10)
fmul f4, f1, f2
fmadd f4, f0, f3, f4
stfd f4, 8(r10)
fmul f3, f1, f3
fmsub f2, f0, f2, f3
stfdx f2, r6, r9
addi r9, r9, 16
addi r8, r8, 1
cmpw cr0, r8, r4
ble .LBB_foo_3 ; no_exit.1


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22781 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c60fb08f7ee00be0aa62c9bf92fd361a2d07c229 13-Aug-2005 Chris Lattner <sabre@nondot.org> When splitting critical edges, make sure not to leave the new block in the
middle of the loop. This turns a critical loop in gzip into this:

.LBB_test_1: ; loopentry
or r27, r28, r28
add r28, r3, r27
lhz r28, 3(r28)
add r26, r4, r27
lhz r26, 3(r26)
cmpw cr0, r28, r26
bne .LBB_test_8 ; loopentry.loopexit_crit_edge
.LBB_test_2: ; shortcirc_next.0
add r28, r3, r27
lhz r28, 5(r28)
add r26, r4, r27
lhz r26, 5(r26)
cmpw cr0, r28, r26
bne .LBB_test_7 ; shortcirc_next.0.loopexit_crit_edge
.LBB_test_3: ; shortcirc_next.1
add r28, r3, r27
lhz r28, 7(r28)
add r26, r4, r27
lhz r26, 7(r26)
cmpw cr0, r28, r26
bne .LBB_test_6 ; shortcirc_next.1.loopexit_crit_edge
.LBB_test_4: ; shortcirc_next.2
add r28, r3, r27
lhz r26, 9(r28)
add r28, r4, r27
lhz r25, 9(r28)
addi r28, r27, 8
cmpw cr7, r26, r25
mfcr r26, 1
rlwinm r26, r26, 31, 31, 31
add r25, r8, r27
cmpw cr7, r25, r7
mfcr r25, 1
rlwinm r25, r25, 29, 31, 31
and. r26, r26, r25
bne .LBB_test_1 ; loopentry

instead of this:

.LBB_test_1: ; loopentry
or r27, r28, r28
add r28, r3, r27
lhz r28, 3(r28)
add r26, r4, r27
lhz r26, 3(r26)
cmpw cr0, r28, r26
beq .LBB_test_3 ; shortcirc_next.0
.LBB_test_2: ; loopentry.loopexit_crit_edge
add r2, r30, r27
add r8, r29, r27
b .LBB_test_9 ; loopexit
.LBB_test_3: ; shortcirc_next.0
add r28, r3, r27
lhz r28, 5(r28)
add r26, r4, r27
lhz r26, 5(r26)
cmpw cr0, r28, r26
beq .LBB_test_5 ; shortcirc_next.1
.LBB_test_4: ; shortcirc_next.0.loopexit_crit_edge
add r2, r11, r27
add r8, r12, r27
b .LBB_test_9 ; loopexit
.LBB_test_5: ; shortcirc_next.1
add r28, r3, r27
lhz r28, 7(r28)
add r26, r4, r27
lhz r26, 7(r26)
cmpw cr0, r28, r26
beq .LBB_test_7 ; shortcirc_next.2
.LBB_test_6: ; shortcirc_next.1.loopexit_crit_edge
add r2, r9, r27
add r8, r10, r27
b .LBB_test_9 ; loopexit
.LBB_test_7: ; shortcirc_next.2
add r28, r3, r27
lhz r26, 9(r28)
add r28, r4, r27
lhz r25, 9(r28)
addi r28, r27, 8
cmpw cr7, r26, r25
mfcr r26, 1
rlwinm r26, r26, 31, 31, 31
add r25, r8, r27
cmpw cr7, r25, r7
mfcr r25, 1
rlwinm r25, r25, 29, 31, 31
and. r26, r26, r25
bne .LBB_test_1 ; loopentry

Next up, improve the code for the loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22769 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e0391beda88c6c441ce1aadbe223d6c0784061a2 13-Aug-2005 Chris Lattner <sabre@nondot.org> Fix a FIXME: if we are inserting code for a PHI argument, split the critical
edge so that the code is not always executed for both operands. This
prevents LSR from inserting code into loops whose exit blocks contain
PHI uses of IV expressions (which are outside of loops). On gzip, for
example, we turn this ugly code:

.LBB_test_1: ; loopentry
add r27, r3, r28
lhz r27, 3(r27)
add r26, r4, r28
lhz r26, 3(r26)
add r25, r30, r28 ;; Only live if exiting the loop
add r24, r29, r28 ;; Only live if exiting the loop
cmpw cr0, r27, r26
bne .LBB_test_5 ; loopexit

into this:

.LBB_test_1: ; loopentry
or r27, r28, r28
add r28, r3, r27
lhz r28, 3(r28)
add r26, r4, r27
lhz r26, 3(r26)
cmpw cr0, r28, r26
beq .LBB_test_3 ; shortcirc_next.0
.LBB_test_2: ; loopentry.loopexit_crit_edge
add r2, r30, r27
add r8, r29, r27
b .LBB_test_9 ; loopexit
.LBB_test_2: ; shortcirc_next.0
...
blt .LBB_test_1


into this:

.LBB_test_1: ; loopentry
or r27, r28, r28
add r28, r3, r27
lhz r28, 3(r28)
add r26, r4, r27
lhz r26, 3(r26)
cmpw cr0, r28, r26
beq .LBB_test_3 ; shortcirc_next.0
.LBB_test_2: ; loopentry.loopexit_crit_edge
add r2, r30, r27
add r8, r29, r27
b .LBB_t_3: ; shortcirc_next.0
.LBB_test_3: ; shortcirc_next.0
...
blt .LBB_test_1


Next step: get the block out of the loop so that the loop is all
fall-throughs again.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22766 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
50fad70279fa982fcd6a72c919f4e18ad99829b9 10-Aug-2005 Chris Lattner <sabre@nondot.org> Teach LSR to strength reduce IVs that have a loop-invariant but non-constant stride.

For code like this:

void foo(float *a, float *b, int n, int stride_a, int stride_b) {
int i;
for (i=0; i<n; i++)
a[i*stride_a] = b[i*stride_b];
}

we now emit:

.LBB_foo2_2: ; no_exit
lfs f0, 0(r4)
stfs f0, 0(r3)
addi r7, r7, 1
add r4, r2, r4
add r3, r6, r3
cmpw cr0, r7, r5
blt .LBB_foo2_2 ; no_exit

instead of:

.LBB_foo_2: ; no_exit
mullw r8, r2, r7 ;; multiply!
slwi r8, r8, 2
lfsx f0, r4, r8
mullw r8, r2, r6 ;; multiply!
slwi r8, r8, 2
stfsx f0, r3, r8
addi r2, r2, 1
cmpw cr0, r2, r5
blt .LBB_foo_2 ; no_exit

loops with variable strides occur pretty often. For example, in SPECFP2K
there are 317 variable strides in 177.mesa, 3 in 179.art, 14 in 188.ammp,
56 in 168.wupwise, 36 in 172.mgrid.

Now we can allow indvars to turn functions written like this:

void foo2(float *a, float *b, int n, int stride_a, int stride_b) {
int i, ai = 0, bi = 0;
for (i=0; i<n; i++)
{
a[ai] = b[bi];
ai += stride_a;
bi += stride_b;
}
}

into code like the above for better analysis. With this patch, they generate
identical code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22740 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
c41e34520ab2f8c0bfe2f95546745826f6b34d59 10-Aug-2005 Chris Lattner <sabre@nondot.org> Fix Regression/Transforms/LoopStrengthReduce/phi_node_update_multiple_preds.ll
by being more careful about updating PHI nodes


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22739 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
87265abffc4942bbcfb9c75de31b6c7dffb82be1 10-Aug-2005 Chris Lattner <sabre@nondot.org> Fix some 80 column violations.

Once we compute the evolution for a GEP, tell SE about it. This allows users
of the GEP to know it, if the users are not direct. This allows us to compile
this testcase:

void fbSolidFillmmx(int w, unsigned char *d) {
while (w >= 64) {
*(unsigned long long *) (d + 0) = 0;
*(unsigned long long *) (d + 8) = 0;
*(unsigned long long *) (d + 16) = 0;
*(unsigned long long *) (d + 24) = 0;
*(unsigned long long *) (d + 32) = 0;
*(unsigned long long *) (d + 40) = 0;
*(unsigned long long *) (d + 48) = 0;
*(unsigned long long *) (d + 56) = 0;
w -= 64;
d += 64;
}
}

into:

.LBB_fbSolidFillmmx_2: ; no_exit
li r2, 0
stw r2, 0(r4)
stw r2, 4(r4)
stw r2, 8(r4)
stw r2, 12(r4)
stw r2, 16(r4)
stw r2, 20(r4)
stw r2, 24(r4)
stw r2, 28(r4)
stw r2, 32(r4)
stw r2, 36(r4)
stw r2, 40(r4)
stw r2, 44(r4)
stw r2, 48(r4)
stw r2, 52(r4)
stw r2, 56(r4)
stw r2, 60(r4)
addi r4, r4, 64
addi r3, r3, -64
cmpwi cr0, r3, 63
bgt .LBB_fbSolidFillmmx_2 ; no_exit

instead of:

.LBB_fbSolidFillmmx_2: ; no_exit
li r11, 0
stw r11, 0(r4)
stw r11, 4(r4)
stwx r11, r10, r4
add r12, r10, r4
stw r11, 4(r12)
stwx r11, r9, r4
add r12, r9, r4
stw r11, 4(r12)
stwx r11, r8, r4
add r12, r8, r4
stw r11, 4(r12)
stwx r11, r7, r4
add r12, r7, r4
stw r11, 4(r12)
stwx r11, r6, r4
add r12, r6, r4
stw r11, 4(r12)
stwx r11, r5, r4
add r12, r5, r4
stw r11, 4(r12)
stwx r11, r2, r4
add r12, r2, r4
stw r11, 4(r12)
addi r4, r4, 64
addi r3, r3, -64
cmpwi cr0, r3, 63
bgt .LBB_fbSolidFillmmx_2 ; no_exit


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22737 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b965ee5914bb9cdfd1500f29a4a5aa2a128e69c1 09-Aug-2005 Chris Lattner <sabre@nondot.org> SCEVAddExpr::get() of an empty list is invalid.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22724 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1bbae0cbf212d0356f564d12e8f728be455bdc47 09-Aug-2005 Chris Lattner <sabre@nondot.org> Implement: LoopStrengthReduce/share_ivs.ll

Two changes:
* Only insert one PHI node for each stride. Other values are live in
values. This cannot introduce higher register pressure than the
previous approach, and can take advantage of reg+reg addressing modes.
* Factor common base values out of uses before moving values from the
base to the immediate fields. This improves codegen by starting the
stride-specific PHI node out at a common place for each IV use.

As an example, we used to generate this for a loop in swim:

.LBB_main_no_exit_2E_6_2E_i_no_exit_2E_7_2E_i_2: ; no_exit.7.i
lfd f0, 0(r8)
stfd f0, 0(r3)
lfd f0, 0(r6)
stfd f0, 0(r7)
lfd f0, 0(r2)
stfd f0, 0(r5)
addi r9, r9, 1
addi r2, r2, 8
addi r5, r5, 8
addi r6, r6, 8
addi r7, r7, 8
addi r8, r8, 8
addi r3, r3, 8
cmpw cr0, r9, r4
bgt .LBB_main_no_exit_2E_6_2E_i_no_exit_2E_7_2E_i_1

now we emit:

.LBB_main_no_exit_2E_6_2E_i_no_exit_2E_7_2E_i_2: ; no_exit.7.i
lfdx f0, r8, r2
stfdx f0, r9, r2
lfdx f0, r5, r2
stfdx f0, r7, r2
lfdx f0, r3, r2
stfdx f0, r6, r2
addi r10, r10, 1
addi r2, r2, 8
cmpw cr0, r10, r4
bgt .LBB_main_no_exit_2E_6_2E_i_no_exit_2E_7_2E_i_1

As another more dramatic example, we used to emit this:

.LBB_main_L_90_no_exit_2E_0_2E_i16_no_exit_2E_1_2E_i19_2: ; no_exit.1.i19
lfd f0, 8(r21)
lfd f4, 8(r3)
lfd f5, 8(r27)
lfd f6, 8(r22)
lfd f7, 8(r5)
lfd f8, 8(r6)
lfd f9, 8(r30)
lfd f10, 8(r11)
lfd f11, 8(r12)
fsub f10, f10, f11
fadd f5, f4, f5
fmul f5, f5, f1
fadd f6, f6, f7
fadd f6, f6, f8
fadd f6, f6, f9
fmadd f0, f5, f6, f0
fnmsub f0, f10, f2, f0
stfd f0, 8(r4)
lfd f0, 8(r25)
lfd f5, 8(r26)
lfd f6, 8(r23)
lfd f9, 8(r28)
lfd f10, 8(r10)
lfd f12, 8(r9)
lfd f13, 8(r29)
fsub f11, f13, f11
fadd f4, f4, f5
fmul f4, f4, f1
fadd f5, f6, f9
fadd f5, f5, f10
fadd f5, f5, f12
fnmsub f0, f4, f5, f0
fnmsub f0, f11, f3, f0
stfd f0, 8(r24)
lfd f0, 8(r8)
fsub f4, f7, f8
fsub f5, f12, f10
fnmsub f0, f5, f2, f0
fnmsub f0, f4, f3, f0
stfd f0, 8(r2)
addi r20, r20, 1
addi r2, r2, 8
addi r8, r8, 8
addi r10, r10, 8
addi r12, r12, 8
addi r6, r6, 8
addi r29, r29, 8
addi r28, r28, 8
addi r26, r26, 8
addi r25, r25, 8
addi r24, r24, 8
addi r5, r5, 8
addi r23, r23, 8
addi r22, r22, 8
addi r3, r3, 8
addi r9, r9, 8
addi r11, r11, 8
addi r30, r30, 8
addi r27, r27, 8
addi r21, r21, 8
addi r4, r4, 8
cmpw cr0, r20, r7
bgt .LBB_main_L_90_no_exit_2E_0_2E_i16_no_exit_2E_1_2E_i19_1

we now emit:

.LBB_main_L_90_no_exit_2E_0_2E_i16_no_exit_2E_1_2E_i19_2: ; no_exit.1.i19
lfdx f0, r21, r20
lfdx f4, r3, r20
lfdx f5, r27, r20
lfdx f6, r22, r20
lfdx f7, r5, r20
lfdx f8, r6, r20
lfdx f9, r30, r20
lfdx f10, r11, r20
lfdx f11, r12, r20
fsub f10, f10, f11
fadd f5, f4, f5
fmul f5, f5, f1
fadd f6, f6, f7
fadd f6, f6, f8
fadd f6, f6, f9
fmadd f0, f5, f6, f0
fnmsub f0, f10, f2, f0
stfdx f0, r4, r20
lfdx f0, r25, r20
lfdx f5, r26, r20
lfdx f6, r23, r20
lfdx f9, r28, r20
lfdx f10, r10, r20
lfdx f12, r9, r20
lfdx f13, r29, r20
fsub f11, f13, f11
fadd f4, f4, f5
fmul f4, f4, f1
fadd f5, f6, f9
fadd f5, f5, f10
fadd f5, f5, f12
fnmsub f0, f4, f5, f0
fnmsub f0, f11, f3, f0
stfdx f0, r24, r20
lfdx f0, r8, r20
fsub f4, f7, f8
fsub f5, f12, f10
fnmsub f0, f5, f2, f0
fnmsub f0, f4, f3, f0
stfdx f0, r2, r20
addi r19, r19, 1
addi r20, r20, 8
cmpw cr0, r19, r7
bgt .LBB_main_L_90_no_exit_2E_0_2E_i16_no_exit_2E_1_2E_i19_1


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22722 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a553b0cc014bc0fb0d5d4820ec2725e733c60003 09-Aug-2005 Chris Lattner <sabre@nondot.org> Suck the base value out of the UsersToProcess vector into the BasedUser
class to simplify the code. Fuse two loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22721 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
44b807e3c0b358d75f153066b2b7556710d9c7cc 09-Aug-2005 Chris Lattner <sabre@nondot.org> Split MoveLoopVariantsToImediateField out from MoveImmediateValues. The
first is a correctness thing, and the later is an optzn thing. This also
is needed to support a future change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22720 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3821e478a574b80d7f8bc96fa42731291cfccfe8 08-Aug-2005 Chris Lattner <sabre@nondot.org> Not all constants are legal immediates in load/store instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22704 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5272f3c669c7a2d43dd4796aded314ecc00c66b8 08-Aug-2005 Chris Lattner <sabre@nondot.org> Implement LoopStrengthReduce/share_code_in_preheader.ll by having one
rewriter for all code inserted into the preheader, which is never flushed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22702 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
010de25f42dabbb7e0a2fe8b42aecc4285362e0c 08-Aug-2005 Chris Lattner <sabre@nondot.org> Implement a simple optimization for the termination condition of the loop.
The termination condition actually wants to use the post-incremented value
of the loop, not a new indvar with an unusual base.

On PPC, for example, this allows us to compile
LoopStrengthReduce/exit_compare_live_range.ll to:

_foo:
li r2, 0
.LBB_foo_1: ; no_exit
li r5, 0
stw r5, 0(r3)
addi r2, r2, 1
cmpw cr0, r2, r4
bne .LBB_foo_1 ; no_exit
blr

instead of:

_foo:
li r2, 1 ;; IV starts at 1, not 0
.LBB_foo_1: ; no_exit
li r5, 0
stw r5, 0(r3)
addi r5, r2, 1
cmpw cr0, r2, r4
or r2, r5, r5 ;; Reg-reg copy, extra live range
bne .LBB_foo_1 ; no_exit
blr

This implements LoopStrengthReduce/exit_compare_live_range.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22699 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
9a59fbb89606aaefb27f6fe07dcb7c188bf1b3cd 05-Aug-2005 Chris Lattner <sabre@nondot.org> Make sure to clean CastedPointers after casts are potentially deleted.
This fixes LSR crashes on 301.apsi, 191.fma3d, and 189.lucas


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22673 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
26d91f16464db56283087176a73981048331dd2d 05-Aug-2005 Chris Lattner <sabre@nondot.org> Modify how immediates are removed from base expressions to deal with the fact
that the symbolic evaluator is not always able to use subtraction to remove
expressions. This makes the code faster, and fixes the last crash on 178.galgel.
Finally, add a statistic to see how many phi nodes are inserted.

On 178.galgel, we get the follow stats:

2562 loop-reduce - Number of PHIs inserted
3927 loop-reduce - Number of GEPs strength reduced


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22662 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2114b273ef0520cec99c253ef6ddf717eaa7657a 04-Aug-2005 Chris Lattner <sabre@nondot.org> * Refactor some code into a new BasedUser::RewriteInstructionToUseNewBase
method.
* Fix a crash on 178.galgel, where we would insert expressions before PHI
nodes instead of into the PHI node predecessor blocks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22657 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7a2ca56ef3bdda6874bcd4df2910fb5a33999f85 04-Aug-2005 Chris Lattner <sabre@nondot.org> Fix a case that caused this to crash on 178.galgel


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22653 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7db543f887c83aad2a95814a16d363a2313fc2a8 04-Aug-2005 Chris Lattner <sabre@nondot.org> Teach LSR about loop-variant expressions, such as loops like this:

for (i = 0; i < N; ++i)
A[i][foo()] = 0;

here we still want to strength reduce the A[i] part, even though foo() is
l-v.

This also simplifies some of the 'CanReduce' logic.

This implements Transforms/LoopStrengthReduce/ops_after_indvar.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22652 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f08341457f8b79f5a138677cb7d0f03a80f6c9c2 04-Aug-2005 Nate Begeman <natebegeman@mac.com> Remove some more dead code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22650 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3416e5f645186a7e3321f927eab662d0ecef404b 04-Aug-2005 Chris Lattner <sabre@nondot.org> Refactor this code substantially with the following improvements:
1. We only analyze instructions once, guaranteed
2. AnalyzeGetElementPtrUsers has been ripped apart and replaced with
something much simpler.

The next step is to handle expressions that are not all indvar+loop-invariant
values (e.g. handling indvar+loopvariant).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22649 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
49f72e68cf6eb77b5791310513d94dc64dc6ea7d 04-Aug-2005 Chris Lattner <sabre@nondot.org> refactor some code


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22643 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
a4479ad25f7f184fc4600beb1d39fd1e71849c4d 04-Aug-2005 Chris Lattner <sabre@nondot.org> invert to if's to make the logic simpler


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22641 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f9186596f06f2c1c5357420d44e2fe2f38f98068 04-Aug-2005 Chris Lattner <sabre@nondot.org> When processing outer loops and we find uses of an IV in inner loops, make
sure to handle the use, just don't recurse into it.

This permits us to generate this code for a simple nested loop case:

.LBB_foo_0: ; entry
stwu r1, -48(r1)
stw r29, 44(r1)
stw r30, 40(r1)
mflr r11
stw r11, 56(r1)
lis r2, ha16(L_A$non_lazy_ptr)
lwz r30, lo16(L_A$non_lazy_ptr)(r2)
li r29, 1
.LBB_foo_1: ; no_exit.0
bl L_bar$stub
li r2, 1
or r3, r30, r30
.LBB_foo_2: ; no_exit.1
lfd f0, 8(r3)
stfd f0, 0(r3)
addi r4, r2, 1
addi r3, r3, 8
cmpwi cr0, r2, 100
or r2, r4, r4
bne .LBB_foo_2 ; no_exit.1
.LBB_foo_3: ; loopexit.1
addi r30, r30, 800
addi r2, r29, 1
cmpwi cr0, r29, 100
or r29, r2, r2
bne .LBB_foo_1 ; no_exit.0
.LBB_foo_4: ; return
lwz r11, 56(r1)
mtlr r11
lwz r30, 40(r1)
lwz r29, 44(r1)
lwz r1, 0(r1)
blr

instead of this:

_foo:
.LBB_foo_0: ; entry
stwu r1, -48(r1)
stw r28, 44(r1) ;; uses an extra register.
stw r29, 40(r1)
stw r30, 36(r1)
mflr r11
stw r11, 56(r1)
li r30, 1
li r29, 0
or r28, r29, r29
.LBB_foo_1: ; no_exit.0
bl L_bar$stub
mulli r2, r28, 800 ;; unstrength-reduced multiply
lis r3, ha16(L_A$non_lazy_ptr) ;; loop invariant address computation
lwz r3, lo16(L_A$non_lazy_ptr)(r3)
add r2, r2, r3
mulli r4, r29, 800 ;; unstrength-reduced multiply
addi r3, r3, 8
add r3, r4, r3
li r4, 1
.LBB_foo_2: ; no_exit.1
lfd f0, 0(r3)
stfd f0, 0(r2)
addi r5, r4, 1
addi r2, r2, 8 ;; multiple stride 8 IV's
addi r3, r3, 8
cmpwi cr0, r4, 100
or r4, r5, r5
bne .LBB_foo_2 ; no_exit.1
.LBB_foo_3: ; loopexit.1
addi r28, r28, 1 ;;; Many IV's with stride 1
addi r29, r29, 1
addi r2, r30, 1
cmpwi cr0, r30, 100
or r30, r2, r2
bne .LBB_foo_1 ; no_exit.0
.LBB_foo_4: ; return
lwz r11, 56(r1)
mtlr r11
lwz r30, 36(r1)
lwz r29, 40(r1)
lwz r28, 44(r1)
lwz r1, 0(r1)
blr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22640 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7a65839f4118c99fb1636c3cbb41b0bf7ef27665 04-Aug-2005 Chris Lattner <sabre@nondot.org> Teach loop-reduce to see into nested loops, to pull out immediate values
pushed down by SCEV.

In a nested loop case, this allows us to emit this:

lis r3, ha16(L_A$non_lazy_ptr)
lwz r3, lo16(L_A$non_lazy_ptr)(r3)
add r2, r2, r3
li r3, 1
.LBB_foo_2: ; no_exit.1
lfd f0, 8(r2) ;; Uses offset of 8 instead of 0
stfd f0, 0(r2)
addi r4, r3, 1
addi r2, r2, 8
cmpwi cr0, r3, 100
or r3, r4, r4
bne .LBB_foo_2 ; no_exit.1

instead of this:

lis r3, ha16(L_A$non_lazy_ptr)
lwz r3, lo16(L_A$non_lazy_ptr)(r3)
add r2, r2, r3
addi r3, r3, 8
li r4, 1
.LBB_foo_2: ; no_exit.1
lfd f0, 0(r3)
stfd f0, 0(r2)
addi r5, r4, 1
addi r2, r2, 8
addi r3, r3, 8
cmpwi cr0, r4, 100
or r4, r5, r5
bne .LBB_foo_2 ; no_exit.1


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22639 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
be3e5212e23edc9210f774fac18d801de252e906 04-Aug-2005 Chris Lattner <sabre@nondot.org> improve debug output


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22638 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2351abaeab89ef0a0df5a715d0794ed5dec48bb3 04-Aug-2005 Chris Lattner <sabre@nondot.org> Move from Stage 0 to Stage 1.

Only emit one PHI node for IV uses with identical bases and strides (after
moving foldable immediates to the load/store instruction).

This implements LoopStrengthReduce/dont_insert_redundant_ops.ll, allowing
us to generate this PPC code for test1:

or r30, r3, r3
.LBB_test1_1: ; Loop
li r2, 0
stw r2, 0(r30)
stw r2, 4(r30)
bl L_pred$stub
addi r30, r30, 8
cmplwi cr0, r3, 0
bne .LBB_test1_1 ; Loop

instead of this code:

or r30, r3, r3
or r29, r3, r3
.LBB_test1_1: ; Loop
li r2, 0
stw r2, 0(r29)
stw r2, 4(r30)
bl L_pred$stub
addi r30, r30, 8 ;; Two iv's with step of 8
addi r29, r29, 8
cmplwi cr0, r3, 0
bne .LBB_test1_1 ; Loop


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22635 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
ec3fb63af27b6a20f4a9ee58bb63baad5640ea9c 04-Aug-2005 Chris Lattner <sabre@nondot.org> Rename IVUse to IVUsersOfOneStride, use a struct instead of a pair to
unify some parallel vectors and get field names more descriptive than
"first" and "second". This isn't lisp afterall :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22633 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
52d83e66ee881f85d8a2ccac0183766a6386bfc9 03-Aug-2005 Chris Lattner <sabre@nondot.org> Fix a nasty dangling pointer issue. The ScalarEvolution pass would keep a
map from instruction* to SCEVHandles. When we delete instructions, we have
to tell it about it. We would run into nasty cases where new instructions
were reallocated at old instruction addresses and get the old map values.
Bad bad bad :(


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22632 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
8105c76da440280779a0b658318ac45edf5fccaa 02-Aug-2005 Chris Lattner <sabre@nondot.org> Like the comment says, do not insert cast instructions before phi nodes


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22586 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
7e608bbb5dfe4f827e64e91b0bb68a1d95d737ae 02-Aug-2005 Chris Lattner <sabre@nondot.org> add a comment, make a check more lenient


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22581 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e9100c69cbfbcc9298b663d80ef4ddf31d7bba69 02-Aug-2005 Chris Lattner <sabre@nondot.org> Simplify for loop, clear a per-loop map after processing each loop


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22580 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
07cd0ff29802bb36649ed5de5bc39e2210f91c2d 02-Aug-2005 Chris Lattner <sabre@nondot.org> Add a comment
Make LSR ignore GEP's that have loop variant base values, as we currently
cannot codegen them


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22576 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
1060e09fb207ed778581957671f8803d2df3a581 02-Aug-2005 Chris Lattner <sabre@nondot.org> Fix an iterator invalidation problem


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22575 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
d29b6aa608d69f19b57ebd2ae630b040b1c4951d 30-Jul-2005 Jeff Cohen <jeffc@jolt-lang.org> Keep tabs and trailing spaces out.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22565 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
cfb1d4235fe3291028341e6acf4139723b4749e3 30-Jul-2005 Jeff Cohen <jeffc@jolt-lang.org> Fix VC++ build problems.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22564 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f84d5ab5df5900dcaf90df8d83c16b6cea22f087 30-Jul-2005 Nate Begeman <natebegeman@mac.com> Ack, typo


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22560 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
169974856781a1ce27af9ce6220c390b20c9e6dd 30-Jul-2005 Nate Begeman <natebegeman@mac.com> Commit a new LoopStrengthReduce pass that can use scalar evolutions and
target data to decide which loop induction variables to strength reduce
and how to do so. This work is mostly by Chris Lattner, with tweaks by
me to get it working on some of MultiSource.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22558 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
fd93908ae8b9684fe71c239e3c6cfe13ff6a2663 22-Apr-2005 Misha Brukman <brukman+llvm@gmail.com> Remove trailing whitespace


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21427 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2f62fdc9a71d790d381d7f17d16e7098e30217e3 06-Mar-2005 Chris Lattner <sabre@nondot.org> fix a bug where we thought arguments were constants :(


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20506 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3f93197098e8c553fefdc2a1b6444838c222695b 06-Mar-2005 Chris Lattner <sabre@nondot.org> Fix Regression/Transforms/LoopStrengthReduce/dont_insert_redundant_ops.ll,
hopefully not breaking too many other things.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20505 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2f9b19b4c9ea7a36092725a2e2c36ae2015df785 06-Mar-2005 Chris Lattner <sabre@nondot.org> implement Transforms/LoopStrengthReduce/invariant_value_first_arg.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20501 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2461dff0700d0e34b9854d96a5cc03921b375525 06-Mar-2005 Chris Lattner <sabre@nondot.org> minor simplifications of the code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20497 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
e43dd1b8e7bcbb7bd38b90e05147c1d31ad41cb9 05-Mar-2005 Jeff Cohen <jeffc@jolt-lang.org> Reformat comments to fix 80 columns.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20467 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b21bf9a8d582a40142a322f508a2e8c2c2164893 05-Mar-2005 Jeff Cohen <jeffc@jolt-lang.org> Reuse induction variables created for strength-reduced GEPs by other similar GEPs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20466 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
2f3c9b7562bcdc1795b2bd0ca28b283a8e972826 04-Mar-2005 Jeff Cohen <jeffc@jolt-lang.org> Add support for not strength reducing GEPs where the element size is a small
power of two. This emphatically includes the zeroeth power of two.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20429 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
0456e4a079de51087978c177b1de63343731f4fb 01-Mar-2005 Jeff Cohen <jeffc@jolt-lang.org> Fixed the following LSR bugs:

* Loop invariant code does not dominate the loop header, but rather
the end of the loop preheader.

* The base for a reduced GEP isn't a constant unless all of its
operands (preceding the induction variable) are constant.

* Allow induction variable elimination for the simple case after all.

Also made changes recommended by Chris for properly deleting
instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20383 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
14dc6380814497b600e2ffb50790ef210899712f 28-Feb-2005 Jeff Cohen <jeffc@jolt-lang.org> Fix crash in LSR due to attempt to remove original induction variable. However,
for reasons explained in the comments, I also deactivated this code as it needs
more thought.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20367 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5e1e5e13ffeb4f1f61858f1073c31ad5e9d967b1 27-Feb-2005 Jeff Cohen <jeffc@jolt-lang.org> PHI nodes were incorrectly placed when more than one GEP is reduced in a loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20360 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
f465db6c6a5a877aa791abfc3837d62c491dacd5 27-Feb-2005 Jeff Cohen <jeffc@jolt-lang.org> First pass at improved Loop Strength Reduction. Still not yet ready for prime time.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20358 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
eaa13851a7fe604363577350c5cf65c257c4d41a 18-Oct-2004 Nate Begeman <natebegeman@mac.com> Initial implementation of the strength reduction for GEP instructions in
loops. This optimization is not turned on by default yet, but may be run
with the opt tool's -loop-reduce flag. There are many FIXMEs listed in the
code that will make it far more applicable to a wide range of code, but you
have to start somewhere :)

This limited version currently triggers on the following tests in the
MultiSource directory:
pcompress2: 7 times
cfrac: 5 times
anagram: 2 times
ks: 6 times
yacr2: 2 times


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17134 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp