Teach loop-idiom to turn a loop containing a memset into a larger memset
authorChris Lattner <sabre@nondot.org>
Tue, 4 Jan 2011 07:46:33 +0000 (07:46 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 4 Jan 2011 07:46:33 +0000 (07:46 +0000)
commite41d3c015ce5cafde305d9a6d9baaae1c41bf46a
tree72c2cb4742fdf2d7ee5d0fb96df8911bcba0e7a0
parentb7e9ef0ed1e246bd64d97a768555c8334c0d86e9
Teach loop-idiom to turn a loop containing a memset into a larger memset
when safe.

The testcase is basically this nested loop:
void foo(char *X) {
  for (int i = 0; i != 100; ++i)
    for (int j = 0; j != 100; ++j)
      X[j+i*100] = 0;
}

which gets turned into a single memset now.  clang -O3 doesn't optimize
this yet though due to a phase ordering issue I haven't analyzed yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122806 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/LoopIdiomRecognize.cpp
test/Transforms/LoopIdiom/basic.ll