[PATCH] D125235: [LoopVectorize] Add overflow checks when tail-folding with scalable vectors

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 9 08:04:32 PDT 2022


david-arm created this revision.
david-arm added reviewers: sdesmalen, paulwalker-arm, fhahn, frasercrmck, kmclaughlin.
Herald added subscribers: zzheng, hiraditya.
Herald added a project: All.
david-arm requested review of this revision.
Herald added subscribers: llvm-commits, alextsao1999.
Herald added a project: LLVM.

In InnerLoopVectorizer::getOrCreateVectorTripCount there is an
assert that the known minimum value for the VF is a power of 2
when tail-folding is enabled. However, for scalable vectors the
value of vscale may not be a power of 2, which means we have
to worry about the possibility of overflow. I have solved this
problem by adding preheader checks that prevent us from entering
the vector body if the canonical IV would overflow, i.e.

  if ((IntMax - TripCount) < (VF * UF)) ... skip vector loop ...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125235

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/AArch64/sve-tail-folding-forced.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-tail-folding-unroll.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-tail-folding.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125235.428085.patch
Type: text/x-patch
Size: 86269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220509/1ad8eb23/attachment-0001.bin>


More information about the llvm-commits mailing list