[llvm] [LV][VPlan] Not adding shuffle cost when store loop invariant value. (PR #109644)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 23 04:58:43 PDT 2024


================
@@ -5666,7 +5666,10 @@ LoopVectorizationCostModel::getConsecutiveMemOpCost(Instruction *I,
   }
 
   bool Reverse = ConsecutiveStride < 0;
-  if (Reverse)
+  const StoreInst *SI = dyn_cast<StoreInst>(I);
+  bool IsLoopInvariantStoreValue =
+      SI && Legal->isInvariant(const_cast<StoreInst *>(SI)->getValueOperand());
----------------
fhahn wrote:

isInvariant uses SCEV to determine loop-invariance, while isLiveIn only returns true for values defined outside the VPlan. This may introduce additional divergences, where the operand is invariant via SCEV but defined inside the loop

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


More information about the llvm-commits mailing list