[llvm] [SLP]Improve reordering for consts, splats and ops from same nodes + improved analysis. (PR #87091)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 29 10:02:13 PDT 2024


================
@@ -2068,22 +2100,37 @@ class BoUpSLP {
           OperandData &Data = getData(OpI, Ln);
           if (Data.APO != OpAPO || Data.IsUsed)
             continue;
-          if (Data.V == Op) {
+          Value *OpILane = getValue(OpI, Lane);
+          bool IsConstantOp = isa<Constant>(OpILane);
+          if (Data.V == Op ||
+              (!IsConstantOp &&
+               ((Lns > 2 && isa<Constant>(Data.V)) ||
+                (Lns == 2 &&
+                 !getSameOpcode({Op, getValue((OpI + 1) % OpE, Ln)}, TLI)
+                      .getOpcode() &&
+                 isa<Constant>(Data.V)))) ||
+              (IsInvariant && !isa<Constant>(Data.V) &&
+               !getSameOpcode({Op, Data.V}, TLI).getOpcode() &&
+               L->isLoopInvariant(Data.V))) {
----------------
alexey-bataev wrote:

Added the comments for better explanation

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


More information about the llvm-commits mailing list