llvm-6502/lib/Analysis
Chris Lattner 673e02b0c3 This nutty patch has been in my tree since before 1.3 went out, and it needs
to go in.  This patch allows us to compute the trip count of loops controlled
by values loaded from constant arrays.  The cannonnical example of this is
strlen when passed a constant argument:

for (int i = 0; "constantstring"[i]; ++i) ;
return i;

In this case, it will compute that the loop executes 14 times, which means
that the exit value of i is 14.  Because of this, the loop gets DCE'd and
we are happy.  This also applies to anything that does similar things, e.g.
loops like this:

  const float Array[] = { 0.1, 2.1, 3.2, 23.21 };
  for (int i = 0; Array[i] < 20; ++i)

and is actually fairly general.

The problem with this is that it almost never triggers.  The reason is that
we run indvars and the loop optimizer only at compile time, which is before
things like strlen and strcpy have been inlined into the program from libc.
Because of this, it almost never is used (it triggers twice in specint2k).

I'm committing it because it DOES work, may be useful in the future, and
doesn't slow us down at all.  If/when we start running the loop optimizer
at link-time (-O4?) this will be very nice indeed :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16926 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-12 01:49:27 +00:00
..
DataStructure
IPA
AliasAnalysis.cpp
AliasAnalysisCounter.cpp
AliasAnalysisEvaluator.cpp
AliasSetTracker.cpp
BasicAliasAnalysis.cpp
CFGPrinter.cpp
ConstantRange.cpp
Expressions.cpp
InstCount.cpp
Interval.cpp
IntervalPartition.cpp
LoadValueNumbering.cpp
LoopInfo.cpp
Makefile
Makefile.am
PostDominators.cpp
ProfileInfo.cpp
ProfileInfoLoader.cpp
ProfileInfoLoaderPass.cpp
ScalarEvolution.cpp This nutty patch has been in my tree since before 1.3 went out, and it needs 2004-10-12 01:49:27 +00:00
Trace.cpp
ValueNumbering.cpp