[PATCH] D135808: [LoopInterchange] Correcting the profitability checking for vectorization
Ramkrishnan Narayanan Komala via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 20 13:47:59 PDT 2022
ram-NK updated this revision to Diff 469339.
ram-NK marked an inline comment as done.
ram-NK edited the summary of this revision.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135808/new/
https://reviews.llvm.org/D135808
Files:
llvm/lib/Transforms/Scalar/LoopInterchange.cpp
Index: llvm/lib/Transforms/Scalar/LoopInterchange.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopInterchange.cpp
+++ llvm/lib/Transforms/Scalar/LoopInterchange.cpp
@@ -1113,18 +1113,19 @@
static bool isProfitableForVectorization(unsigned InnerLoopId,
unsigned OuterLoopId,
CharMatrix &DepMatrix) {
- // TODO: Improve this heuristic to catch more cases.
- // If the inner loop is loop independent or doesn't carry any dependency it is
- // profitable to move this to outer position.
for (auto &Row : DepMatrix) {
- if (Row[InnerLoopId] != 'S' && Row[InnerLoopId] != 'I')
- return false;
- // TODO: We need to improve this heuristic.
+ // If the inner loop is loop independent or doesn't carry any dependency it is
+ // not profitable to move this to outer position, since we are likely able to do
+ // inner loop vectorization already.
+ if (Row[InnerLoopId] == 'I' || Row[InnerLoopId] == '=' )
+ return false;
+ // If the outer loop is not loop independent it is not not profitable to move this
+ // to inner position, since doing so would not enable inner loop parallelism.
if (Row[OuterLoopId] != '=')
return false;
}
- // If outer loop has dependence and inner loop is loop independent then it is
- // profitable to interchange to enable parallelism.
+ // If inner loop has dependence and outer loop is loop independent then it is
+ // profitable to interchange to enable inner loop parallelism.
// If there are no dependences, interchanging will not improve anything.
return !DepMatrix.empty();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135808.469339.patch
Type: text/x-patch
Size: 1711 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221020/9fc5d58c/attachment.bin>
More information about the llvm-commits
mailing list