]> granicus.if.org Git - llvm/commit
[LV] Test once if vector trip count is zero, instead of twice
authorAyal Zaks <ayal.zaks@intel.com>
Wed, 19 Jul 2017 05:16:39 +0000 (05:16 +0000)
committerAyal Zaks <ayal.zaks@intel.com>
Wed, 19 Jul 2017 05:16:39 +0000 (05:16 +0000)
commite1f7499ee7d78143b3d75d503f8adad356a7107d
tree88b010258eca3dde742ac9b9bbbfafe77b275ca3
parent8d9168d095bf449a71fb056e77126f7d0cb9ac04
[LV] Test once if vector trip count is zero, instead of twice

Generate a single test to decide if there are enough iterations to jump to the
vectorized loop, or else go to the scalar remainder loop. This test compares the
Scalar Trip Count: if STC < VF * UF go to the scalar loop. If
requiresScalarEpilogue() holds, at-least one iteration must remain scalar; the
rest can be used to form vector iterations. So in this case the test checks
instead if (STC - 1) < VF * UF by comparing STC <= VF * UF, and going to the
scalar loop if so. Otherwise the vector loop is entered for at-least one vector
iteration.

This test covers the case where incrementing the backedge-taken count will
overflow leading to an incorrect trip count of zero. In this (rare) case we will
also avoid the vector loop and jump to the scalar loop.

This patch simplifies the existing tests and effectively removes the basic-block
originally named "min.iters.checked", leaving the single test in block
"vector.ph".

Original observation and initial patch by Evgeny Stupachenko.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308421 91177308-0d34-0410-b5e6-96231b3b80d8
14 files changed:
lib/Transforms/Vectorize/LoopVectorize.cpp
test/Transforms/LoopVectorize/X86/float-induction-x86.ll
test/Transforms/LoopVectorize/debugloc.ll
test/Transforms/LoopVectorize/first-order-recurrence.ll
test/Transforms/LoopVectorize/float-induction.ll
test/Transforms/LoopVectorize/if-conversion-nest.ll
test/Transforms/LoopVectorize/induction-step.ll
test/Transforms/LoopVectorize/induction.ll
test/Transforms/LoopVectorize/interleaved-accesses-pred-stores.ll
test/Transforms/LoopVectorize/interleaved-accesses.ll
test/Transforms/LoopVectorize/iv_outside_user.ll
test/Transforms/LoopVectorize/miniters.ll
test/Transforms/LoopVectorize/runtime-check-readonly.ll
test/Transforms/LoopVectorize/runtime-check.ll