[llvm] 807d432 - [VPlan] Use properlyDominates predicate for ordering FOR users.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 13 13:25:15 PST 2023
Author: Florian Hahn
Date: 2023-02-13T21:24:58Z
New Revision: 807d43239a5fe0bb93d64925393bb99abbd81a92
URL: https://github.com/llvm/llvm-project/commit/807d43239a5fe0bb93d64925393bb99abbd81a92
DIFF: https://github.com/llvm/llvm-project/commit/807d43239a5fe0bb93d64925393bb99abbd81a92.diff
LOG: [VPlan] Use properlyDominates predicate for ordering FOR users.
The current implementation may return true for A < B and B < A, which
may cause issues if the sort implementation assures this property of the
comperator. This should fix a crash with MSVC.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 10a67081a0d09..568f9ab095e5c 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -549,8 +549,8 @@ static VPRegionBlock *GetReplicateRegion(VPRecipeBase *R) {
return nullptr;
}
-static bool dominates(const VPRecipeBase *A, const VPRecipeBase *B,
- VPDominatorTree &VPDT) {
+static bool properlyDominates(const VPRecipeBase *A, const VPRecipeBase *B,
+ VPDominatorTree &VPDT) {
auto LocalComesBefore = [](const VPRecipeBase *A, const VPRecipeBase *B) {
for (auto &R : *A->getParent()) {
if (&R == A)
@@ -573,7 +573,7 @@ static bool dominates(const VPRecipeBase *A, const VPRecipeBase *B,
ParentA = RegionA->getExiting();
if (RegionB)
ParentB = RegionB->getExiting();
- return VPDT.dominates(ParentA, ParentB);
+ return VPDT.properlyDominates(ParentA, ParentB);
}
// Sink users of \p FOR after the recipe defining the previous value \p Previous
@@ -592,7 +592,7 @@ sinkRecurrenceUsersAfterPrevious(VPFirstOrderRecurrencePHIRecipe *FOR,
"The previous value cannot depend on the users of the recurrence phi.");
if (isa<VPHeaderPHIRecipe>(SinkCandidate) ||
!Seen.insert(SinkCandidate).second ||
- dominates(Previous, SinkCandidate, VPDT))
+ properlyDominates(Previous, SinkCandidate, VPDT))
return;
WorkList.push_back(SinkCandidate);
@@ -613,7 +613,7 @@ sinkRecurrenceUsersAfterPrevious(VPFirstOrderRecurrencePHIRecipe *FOR,
// Keep recipes to sink ordered by dominance so earlier instructions are
// processed first.
sort(WorkList, [&VPDT](const VPRecipeBase *A, const VPRecipeBase *B) {
- return dominates(A, B, VPDT);
+ return properlyDominates(A, B, VPDT);
});
for (VPRecipeBase *SinkCandidate : WorkList) {
More information about the llvm-commits
mailing list