[VPlan] Make sure properlyDominates(A, A) returns false.
authorFlorian Hahn <flo@fhahn.com>
Sun, 19 Feb 2023 18:01:15 +0000 (18:01 +0000)
committerFlorian Hahn <flo@fhahn.com>
Sun, 19 Feb 2023 18:01:16 +0000 (18:01 +0000)
At the moment, properlyDominates(A, A) can return true via
LocalComesBefore. Add an early exit to ensure it returns false if
A == B.

Note: no test has been added because the existing test suite covers this
case already with libc++ with assertions enabled.

Fixes https://github.com/llvm/llvm-project/issues/60850.

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

index 568f9ab..d3f84da 100644 (file)
@@ -551,6 +551,9 @@ static VPRegionBlock *GetReplicateRegion(VPRecipeBase *R) {
 
 static bool properlyDominates(const VPRecipeBase *A, const VPRecipeBase *B,
                               VPDominatorTree &VPDT) {
+  if (A == B)
+    return false;
+
   auto LocalComesBefore = [](const VPRecipeBase *A, const VPRecipeBase *B) {
     for (auto &R : *A->getParent()) {
       if (&R == A)