[llvm] [VPlan] Add initial loop-invariant code motion transform. (PR #107894)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 05:00:40 PDT 2024


================
@@ -2382,7 +2382,8 @@ void InnerLoopVectorizer::scalarizeInstruction(const Instruction *Instr,
     AC->registerAssumption(II);
 
   // End if-block.
-  bool IfPredicateInstr = RepRecipe->getParent()->getParent()->isReplicator();
+  VPRegionBlock *Parent = RepRecipe->getParent()->getParent();
+  bool IfPredicateInstr = Parent ? Parent->isReplicator() : false;
----------------
fhahn wrote:

Yes it is related. Without it, VPReplicateRecipe::execute will crash here due to a nullpointer dereference when trying to retrieve the recipe's parent region, which doesn't exist when hoisted out.

It could be split off, but the check would be dead code as without the current patch, VPReplicateRecipes will always have a parent region.

https://github.com/llvm/llvm-project/pull/107894


More information about the llvm-commits mailing list