[llvm] [LV] Ensure getScaledReductions only matches extends inside the loop (PR #148264)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 14 00:03:17 PDT 2025


================
@@ -8109,14 +8109,19 @@ bool VPRecipeBuilder::getScaledReductions(
   std::optional<unsigned> BinOpc;
   Type *ExtOpTypes[2] = {nullptr};
 
-  auto CollectExtInfo = [&Exts,
+  auto CollectExtInfo = [this, &Exts,
                          &ExtOpTypes](SmallVectorImpl<Value *> &Ops) -> bool {
     unsigned I = 0;
     for (Value *OpI : Ops) {
       Value *ExtOp;
       if (!match(OpI, m_ZExtOrSExt(m_Value(ExtOp))))
         return false;
       Exts[I] = cast<Instruction>(OpI);
+
+      // Other operand should live inside the loop
+      if (!CM.TheLoop->contains(Exts[I]))
----------------
fhahn wrote:

Is there a reason it is difficult/not possible to support live-in operands? 


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


More information about the llvm-commits mailing list