OSDN Git Service

[LV] Optimize for size when vectorizing loops with tiny trip count
authorAyal Zaks <ayal.zaks@intel.com>
Fri, 30 Jun 2017 08:02:35 +0000 (08:02 +0000)
committerAyal Zaks <ayal.zaks@intel.com>
Fri, 30 Jun 2017 08:02:35 +0000 (08:02 +0000)
commitbfae62c2cbac460e01f5d4bbbaae459e17ad2437
treea16dca697cbc6b13c9cbad07240022957a986db3
parentc9df51e6e959f81e451b5d65dfc274c3ef06d4c2
[LV] Optimize for size when vectorizing loops with tiny trip count

It may be detrimental to vectorize loops with very small trip count, as various
costs of the vectorized loop body as well as enclosing overheads including
runtime tests and scalar iterations may outweigh the gains of vectorizing. The
current cost model measures the cost of the vectorized loop body only, expecting
it will amortize other costs, and loops with known or expected very small trip
counts are not vectorized at all. This patch allows loops with very small trip
counts to be vectorized, but under OptForSize constraints, which ensure the cost
of the loop body is dominant, having no runtime guards nor scalar iterations.

Patch inspired by D32451.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306803 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Vectorize/LoopVectorize.cpp
test/Transforms/LoopVectorize/X86/vect.omp.force.small-tc.ll
test/Transforms/LoopVectorize/small-loop.ll