[PATCH] D30247: Epilog loop vectorization

Ashutosh Nema via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 22 01:46:19 PST 2017


ashutosh.nema created this revision.
Herald added a subscriber: mzolotukhin.

This is a proposal about epilog loop vectorization.

Currently Loop Vectorizer inserts an epilogue loop for handling loops that don’t have known iteration counts.

The Loop Vectorizer supports loops with an unknown trip count, unknown trip count may not be a multiple of the vector width, and the vectorizer has to execute the last few iterations as scalar code. It keeps a scalar copy of the loop for the remaining iterations.

Loop with the large width has a high possibility of executing many scalar iterations.
i.e. i8 data type with 256bits target register can vectorize with vector width 32, with that maximum trip count possibility for scalar(epilog) loop is 31, which is significant & worth vectorizing.

Large vector factor has following challenges:

1. Possibility of remainder iteration is substantial.
2. Actual trip count at runtime is substantial but not meeting minimum trip count to execute vector loop.

These challenges can be addressed by mask instructions, but these instructions are limited and may not be available to all targets.

By epilog vectorization our aim to vectorize epilog loop where original loop is vectorized with large vector factor and has a high possibility of executing scalar iterations.

This require following changes:

1. Costing: Preserve all profitable vector factor.
2. Transform: Create an additional vector loop with next profitable vector factor.

Please refer attached file (BlockLayout.png) for the details about transformed block layout.


Repository:
  rL LLVM

https://reviews.llvm.org/D30247

Files:
  include/llvm/Transforms/Utils/LoopVersioning.h
  lib/Transforms/Utils/LoopVersioning.cpp
  lib/Transforms/Vectorize/LoopVectorize.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30247.89338.patch
Type: text/x-patch
Size: 30728 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170222/b74e5781/attachment-0001.bin>


More information about the llvm-commits mailing list