[PATCH] Loop Rerolling Pass

I mistakenly not cc’ed the list.

What I am proposing for interleaved data vectorization would not transform the loop before vectorization (because there is not much you can do in the general case). There would not be a need for any retries.

I know, I digressed.

We want to run the loop vectorizer late so we can't rely on a other passes to undo the canonicalisation we have done.

I didn't mean to change the code and annotate, but to just annotate the unchanged blocks in case we want to try again, we can avoid re-doing the same analysis.

I've noticed, on the debug-only, that the loop vectorizer passes twice on the same loops, and we even check for validity of previously auto-vectorized loops! This is already a big waste, and if there was a way to avoid that, we could use the saved time for more complex (maybe iterative, speculative) analysis without increasing the compilation time.

Iteresting. This is a bug. Since we moved the loop vectorizer out of the scc-module pass manager we should only run once on every new loop. The vectorized loop is a new loop so runOnLoop will probably be called again. But the Hint we put in the IR should prevent us from analyzing such loops.

I think what you might be seeing is a bug in LoopVectorizerHints:

/// Mark the loop L as already vectorized by setting the width to 1.
  void setAlreadyVectorized(Loop *L)

We should set width *and* unroll to one. Because this is how we use it:

    LoopVectorizeHints Hints(L, DisableUnrolling);

    if (Hints.Width == 1 && Hints.Unroll == 1) {
      DEBUG(dbgs() << "LV: Not vectorizing.\n");
      return false;
    }

After doing this no vectorized loop should be analyzed again. If not I very much like to know.

http://llvm.org/bugs/show_bug.cgi?id=17662

Thanks,
Arnold