[PATCH] D34150: [LV] Test once if vector trip count is zero, instead of twice

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 09:00:59 PDT 2017


Ayal created this revision.
Herald added a subscriber: mzolotukhin.

Before reaching the header block of the vectorized loop, the Loop Vectorizer generates two conditions to make sure the vectorized loop will iterate at-least once: first emitVectorLoopEnteredCheck() compares the Scalar Trip Count to VF*UF, and if the former is not less than the latter, emitMinimumIterationCountCheck() compares the Vector Trip Count to zero.

In general, VTC = STC mod VF*UF, unless this does not comply with an optional constraint to execute at-least a single scalar iteration in the epilog, aka requiresScalarEpilogue(). In this case a single (the last) vector iteration is peeled and replaced with VF*UF scalar iterations (instead of none), reducing VTC by 1.

This patch replaces the above two comparisons for  VTC == 0 with a single comparison:

- STC < VF*UF, when requiresScalarEpilogue() does not hold; or
- STC <= VF*UF, when requiresScalarEpilogue() does hold,

effectively removing the basic-block originally named "min.iters.checked".

The original documentation of emitMinimumIterationCountCheck() claiming it checks for overflow seems obsolete (right?).

Original observation and initial patch by Evgeny Stupachenko.


https://reviews.llvm.org/D34150

Files:
  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/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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34150.102334.patch
Type: text/x-patch
Size: 21240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170613/2ff046a0/attachment.bin>


More information about the llvm-commits mailing list