[LoopUnroll] Keep the loop test only on the first iteration of max-or-zero loops
authorJohn Brawn <john.brawn@arm.com>
Fri, 21 Oct 2016 11:08:48 +0000 (11:08 +0000)
committerJohn Brawn <john.brawn@arm.com>
Fri, 21 Oct 2016 11:08:48 +0000 (11:08 +0000)
commit84b21835f1ed56eb070d8351a8f98233841be402
tree9d62af95edf30a4c96d365de11bacdeea213610d
parent2e8fe804475feab86bbf857b0475d36b56460c19
[LoopUnroll] Keep the loop test only on the first iteration of max-or-zero loops

When we have a loop with a known upper bound on the number of iterations, and
furthermore know that either the number of iterations will be either exactly
that upper bound or zero, then we can fully unroll up to that upper bound
keeping only the first loop test to check for the zero iteration case.

Most of the work here is in plumbing this 'max-or-zero' information from the
part of scalar evolution where it's detected through to loop unrolling. I've
also gone for the safe default of 'false' everywhere but howManyLessThans which
could probably be improved.

Differential Revision: https://reviews.llvm.org/D25682

llvm-svn: 284818
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/include/llvm/Transforms/Utils/UnrollLoop.h
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
llvm/lib/Transforms/Utils/LoopUnroll.cpp
llvm/test/Analysis/ScalarEvolution/trip-count13.ll
llvm/test/Analysis/ScalarEvolution/trip-count14.ll
llvm/test/Transforms/LoopUnroll/full-unroll-keep-first-exit.ll [new file with mode: 0644]