[llvm] 2db71c9 - [VPlan] Simplify code in createReplicateRegion (NFC).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 11 02:48:09 PST 2023


Author: Florian Hahn
Date: 2023-03-11T11:47:23+01:00
New Revision: 2db71c9851e553e847f19420065f5b2b29e5dec3

URL: https://github.com/llvm/llvm-project/commit/2db71c9851e553e847f19420065f5b2b29e5dec3
DIFF: https://github.com/llvm/llvm-project/commit/2db71c9851e553e847f19420065f5b2b29e5dec3.diff

LOG: [VPlan] Simplify code in createReplicateRegion (NFC).

Simplify the code as suggested in D143865.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index df6f3b33fac05..159bbd040b657 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8595,21 +8595,17 @@ VPRecipeBuilder::createReplicateRegion(VPReplicateRecipe *PredRecipe,
       PredRecipe->getUnderlyingInstr(),
       make_range(PredRecipe->op_begin(), std::prev(PredRecipe->op_end())),
       PredRecipe->isUniform());
-  PredRecipe->replaceAllUsesWith(RecipeWithoutMask);
-  PredRecipe->eraseFromParent();
-
-  auto *BOMRecipe = new VPBranchOnMaskRecipe(BlockInMask);
-  auto *Entry = new VPBasicBlock(Twine(RegionName) + ".entry", BOMRecipe);
-  auto *PHIRecipe = RecipeWithoutMask->getNumUsers() == 0
-                        ? nullptr
-                        : new VPPredInstPHIRecipe(RecipeWithoutMask);
-  if (PHIRecipe) {
-    RecipeWithoutMask->replaceAllUsesWith(PHIRecipe);
+  VPPredInstPHIRecipe *PHIRecipe = nullptr;
+  if (PredRecipe->getNumUsers() != 0) {
+    PHIRecipe = new VPPredInstPHIRecipe(RecipeWithoutMask);
+    PredRecipe->replaceAllUsesWith(PHIRecipe);
     PHIRecipe->setOperand(0, RecipeWithoutMask);
   }
-
+  PredRecipe->eraseFromParent();
   auto *Exiting = new VPBasicBlock(Twine(RegionName) + ".continue", PHIRecipe);
   auto *Pred = new VPBasicBlock(Twine(RegionName) + ".if", RecipeWithoutMask);
+  auto *BOMRecipe = new VPBranchOnMaskRecipe(BlockInMask);
+  auto *Entry = new VPBasicBlock(Twine(RegionName) + ".entry", BOMRecipe);
   VPRegionBlock *Region = new VPRegionBlock(Entry, Exiting, RegionName, true);
 
   // Note: first set Entry as region entry and then connect successors starting


        


More information about the llvm-commits mailing list