aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-10-12 01:49:27 +0000
committerChris Lattner <sabre@nondot.org>2004-10-12 01:49:27 +0000
commit673e02b0c37e7a7fa6ffc67bc5e4813a3ce2806d (patch)
treea7ccc4315ffaa3e1495556be7f88a96e7b8bab06 /include
parent989cbd58fb769e920fbf15b6a0fe0888aed553c9 (diff)
downloadexternal_llvm-673e02b0c37e7a7fa6ffc67bc5e4813a3ce2806d.zip
external_llvm-673e02b0c37e7a7fa6ffc67bc5e4813a3ce2806d.tar.gz
external_llvm-673e02b0c37e7a7fa6ffc67bc5e4813a3ce2806d.tar.bz2
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
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions