[PATCH] D143465: [LoopVectorize] Vectorize the reduction pattern of integer min/max with index.
Mel Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 6 23:09:43 PST 2023
Mel-Chen created this revision.
Herald added subscribers: 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 loops:
int idx = ii;
int max = mm;
for (int i = 0; i < n; ++i) {
int x = a[i];
if (max < x) {
max = x;
idx = i;
}
}
and
int idx = ii;
int max = mm;
for (int i = 0; i < n; ++i) {
int x = a[i];
if (max <= x) {
max = x;
idx = i;
}
}
Changes:
- New recurrence kinds: `SelectIVICmp` and `SelectIVFCmp`. This is temporary. Eventually, SelectICmp/SelectFCmp should be able to fully support conditional scalar assignment. At that time, SelectIVICmp/SelectIVFCmp will be removed.
- New recurrence Kinds: `MinMaxFirstIdx` and `MinMaxLastIdx`. This kind is not directly generated by function AddReductionVar, but converted from SelectIVICmp/SelectIVFCmp.
TODOs:
- Have to comfirm the operands of intrinsic and cmp. We can add some check in the end of AddReductionVar. See test case smax_idx_not_vec_1.
- Now have not support that the min/max recurrence without exit instruction. Refer to test case smax_idx_max_no_exit_user.
- Support the min/max recurrence in select(cmp()). Refer to test case smax_idx_select_cmp.
- Support FP min/max recurrence.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143465
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/LoopVectorizationLegality.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
llvm/test/Transforms/LoopVectorize/select-min-index.ll
llvm/test/Transforms/LoopVectorize/smax-idx.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143465.495388.patch
Type: text/x-patch
Size: 79915 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230207/a91ef471/attachment.bin>
More information about the llvm-commits
mailing list