llvm/lib
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
..
Analysis 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
Archive Changes For Bug 352 2004-09-01 22:55:40 +00:00
AsmParser Initial version of automake Makefile.am file. 2004-10-10 20:43:57 +00:00
Bytecode Initial version of automake Makefile.am file. 2004-10-10 20:43:57 +00:00
CodeGen ModuloScheduling has moved to lib/Target/SparcV9 2004-10-10 23:37:40 +00:00
Debugger Initial version of automake Makefile.am file. 2004-10-10 20:43:57 +00:00
ExecutionEngine Initial version of automake Makefile.am file. 2004-10-10 20:43:57 +00:00
Linker Make sure the const bit gets inherited correctly when linking declarations 2004-10-05 02:28:11 +00:00
Support Initial version of automake Makefile.am file. 2004-10-10 20:43:57 +00:00
System Initial version of automake Makefile.am file. 2004-10-10 20:43:57 +00:00
Target Fix a warning that is emitted on the suns 2004-10-11 15:50:40 +00:00
Transforms Fix a REALLY obscure bug in my previous checkin, which was splicing the END 2004-10-12 01:02:29 +00:00
VMCore Allow creation of GEP constantexprs with a vector of value* operands as 2004-10-11 22:52:25 +00:00
Makefile Wrap long line 2004-09-15 01:34:42 +00:00
Makefile.am Initial version of automake Makefile.am file. 2004-10-10 20:43:57 +00:00