[llvm] [SLP]Reduce number of alternate instruction, where possible (PR #128907)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 27 09:56:32 PST 2025


================
@@ -10058,6 +10468,57 @@ void BoUpSLP::transformNodes() {
             E.isAltShuffle() || !allSameBlock(VL)) ||
           allConstant(VL) || isSplat(VL))
         continue;
+      if (ForceLoadGather && E.hasState() && E.getOpcode() == Instruction::Load)
+        continue;
+      auto AreReusedScalars = [&](const TreeEntry *TE,
+                                  function_ref<bool(Value *)> CheckContainer) {
+        return TE->isSame(VL) || all_of(VL, [&](Value *V) {
+                 if (isa<PoisonValue>(V))
+                   return true;
+                 auto *I = dyn_cast<Instruction>(V);
+                 if (!I)
+                   return false;
+                 return is_contained(TE->Scalars, I) || CheckContainer(I);
+               });
+      };
+      if (E.hasState()) {
----------------
hiraditya wrote:

maybe we can outline this part to a separate function. AIUI, these are checks to discard ineligible entries.

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


More information about the llvm-commits mailing list