[llvm] [LV] Add cross-part load overlap heuristic for interleaving (PR #214500)

Sergey Shcherbinin via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 06:48:01 PDT 2026


================
@@ -0,0 +1,288 @@
+//===- VPlanCrossPartCSE.cpp - Cross-part CSE for VPlan -------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements exact load-overlap profitability analysis across two
+// logical VPlan parts.
+//
+//===----------------------------------------------------------------------===//
+
+#include "VPlanCrossPartCSE.h"
+#include "VPlan.h"
+#include "VPlanPatternMatch.h"
+#include "VPlanUtils.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/Hashing.h"
+#include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Analysis/ScalarEvolution.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
+#include <cstdint>
+#include <optional>
+
+using namespace llvm;
+
+#define DEBUG_TYPE "loop-vectorize"
+
+namespace {
+
+/// A simple widened load supported by the prediction-only analysis.
+struct CrossPartSupportedLoad {
+  /// VPlan recipe whose logical UF=2 instances are modeled.
+  VPWidenLoadRecipe *Recipe;
+  /// Underlying scalar load used for type, SCEV, and poison identity.
+  LoadInst *Load;
+};
+
+/// Return an unmasked, non-EVL, consecutive simple widened load.
+static std::optional<CrossPartSupportedLoad>
+getCrossPartSupportedLoad(VPRecipeBase &R) {
+  auto *Widen = dyn_cast<VPWidenLoadRecipe>(&R);
+  if (!Widen || Widen->isMasked() || !Widen->isConsecutive())
+    return std::nullopt;
+
+  auto *Load = dyn_cast<LoadInst>(&Widen->getIngredient());
+  if (!Load || !Load->isSimple())
+    return std::nullopt;
+  return CrossPartSupportedLoad{Widen, Load};
----------------
SergeyShch01 wrote:

Fixed

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


More information about the llvm-commits mailing list