[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:41 PDT 2024
================
@@ -1587,3 +1588,24 @@ void VPlanTransforms::createInterleaveGroups(
}
}
}
+
+void VPlanTransforms::licm(VPlan &Plan) {
+ VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
+ VPBasicBlock *Preheader =
+ cast<VPBasicBlock>(LoopRegion->getSinglePredecessor());
+ // Hoist any loop invariant recipes from the vector loop region to the
+ // preheader.
+ for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
+ vp_depth_first_shallow(LoopRegion->getEntry()))) {
----------------
fhahn wrote:
`vp_depth_first_shallow` will not traverse inside replicate regions in the vector region, which ensures we do not try to hoist out conditionally executed recipes from (predicated) replicate regions.
https://github.com/llvm/llvm-project/pull/107894
More information about the llvm-commits
mailing list