[PATCH] D150851: [LoopVectorize] Vectorize select-cmp reduction pattern for increasing integer induction variable (WIP)

Mel Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 02:43:02 PDT 2023


Mel-Chen created this revision.
Herald added subscribers: hoy, shiva0217, arphaman, rogfer01, hiraditya.
Herald added a project: All.
Mel-Chen requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, vkmr.
Herald added a project: LLVM.

Consider the following loop:

  int red = ii;
  for (int i = 0; i < n; ++i)
    red = (a[i] > b[i]) ? i : red;

We can vectorize this loop if `i` is an increasing induction variable.
The final reduced value will be tha maximum of `i` that the condition
`a[i] > b[i]` is satisfied, or the start value `ii`.

This patch added new RecurKind enums - SelectIVICmp and SelectIVFCmp.

Work-in-progress:

- Add test cases.
- Check the bound of increasing induction variable


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150851

Files:
  llvm/include/llvm/Analysis/IVDescriptors.h
  llvm/include/llvm/Transforms/Utils/LoopUtils.h
  llvm/lib/Analysis/IVDescriptors.cpp
  llvm/lib/Transforms/Utils/LoopUtils.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
  llvm/test/Transforms/LoopVectorize/select-min-index.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150851.523301.patch
Type: text/x-patch
Size: 33869 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230518/927b3c10/attachment.bin>


More information about the llvm-commits mailing list