[llvm] 282af2d - [VPlan] Remove unneeded checks from PlanCFGBuilder::isExternalDef (NFC).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue May 6 11:04:42 PDT 2025


Author: Florian Hahn
Date: 2025-05-06T19:04:22+01:00
New Revision: 282af2ddfcfa14a19e2cf596de370c2ead13d0a9

URL: https://github.com/llvm/llvm-project/commit/282af2ddfcfa14a19e2cf596de370c2ead13d0a9
DIFF: https://github.com/llvm/llvm-project/commit/282af2ddfcfa14a19e2cf596de370c2ead13d0a9.diff

LOG: [VPlan] Remove unneeded checks from PlanCFGBuilder::isExternalDef (NFC).

Remove checking if the instruction is in the preheader or exit blocks.
Those checks are redundant and handled by checking if the instruction is
outside the loop below.

Split off as suggested from https://github.com/llvm/llvm-project/pull/137709.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
index c7132e84f689c..85070565718da 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
@@ -125,9 +125,8 @@ VPBasicBlock *PlainCFGBuilder::getOrCreateVPBB(BasicBlock *BB) {
 // Return true if \p Val is considered an external definition. An external
 // definition is either:
 // 1. A Value that is not an Instruction. This will be refined in the future.
-// 2. An Instruction that is outside of the CFG snippet represented in VPlan,
-// i.e., is not part of: a) the loop nest, b) outermost loop PH and, c)
-// outermost loop exits.
+// 2. An Instruction that is outside of the IR region represented in VPlan,
+// i.e., is not part of the loop nest.
 bool PlainCFGBuilder::isExternalDef(Value *Val) {
   // All the Values that are not Instructions are considered external
   // definitions for now.
@@ -135,25 +134,6 @@ bool PlainCFGBuilder::isExternalDef(Value *Val) {
   if (!Inst)
     return true;
 
-  BasicBlock *InstParent = Inst->getParent();
-  assert(InstParent && "Expected instruction parent.");
-
-  // Check whether Instruction definition is in loop PH.
-  BasicBlock *PH = TheLoop->getLoopPreheader();
-  assert(PH && "Expected loop pre-header.");
-
-  if (InstParent == PH)
-    // Instruction definition is in outermost loop PH.
-    return false;
-
-  // Check whether Instruction definition is in a loop exit.
-  SmallVector<BasicBlock *> ExitBlocks;
-  TheLoop->getExitBlocks(ExitBlocks);
-  if (is_contained(ExitBlocks, InstParent)) {
-    // Instruction definition is in outermost loop exit.
-    return false;
-  }
-
   // Check whether Instruction definition is in loop body.
   return !TheLoop->contains(Inst);
 }


        


More information about the llvm-commits mailing list