[llvm] [LV] Limits the splat operations be hoisted must not be defined by a recipe. (PR #117138)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 18 01:33:20 PST 2025


================
@@ -264,7 +265,11 @@ Value *VPTransformState::get(VPValue *Def, bool NeedsScalar) {
     return Data.VPV2Vector[Def];
 
   auto GetBroadcastInstrs = [this, Def](Value *V) {
-    bool SafeToHoist = Def->isDefinedOutsideLoopRegions();
+    bool SafeToHoist =
+        !Def->hasDefiningRecipe() ||
+        VPDT.properlyDominates(Def->getDefiningRecipe()->getParent(),
+                               Plan->getVectorPreheader());
----------------
Mel-Chen wrote:

Maybe we could use `dominates` instead of `properlyDominates` to achieve this.

However, I don’t understand the benefit of doing so. In my opinion, if `Def` is already defined in the preheader yet we still determine that the corresponding splat operation can be hoisted, this might move the splat operation further away from `Def`, extending `Def`'s live range. (please see the change of `llvm/test/Transforms/LoopVectorize/AArch64/extractvalue-no-scalarization-required.ll`)

I might be missing something—could you please explain the advantages of this change in more detail?

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


More information about the llvm-commits mailing list