[llvm] [VPlan] Move predication to VPlanTransform (NFC). (PR #128420)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri May 16 03:31:05 PDT 2025
================
@@ -0,0 +1,298 @@
+//===-- VPlanPredicator.cpp - VPlan predicator ----------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file implements predication for VPlans.
+///
+//===----------------------------------------------------------------------===//
+
+#include "VPRecipeBuilder.h"
+#include "VPlan.h"
+#include "VPlanCFG.h"
+#include "VPlanTransforms.h"
+#include "VPlanUtils.h"
+#include "llvm/ADT/PostOrderIterator.h"
+
+using namespace llvm;
+
+namespace {
+struct VPPredicator {
+ using BlockMaskCacheTy = DenseMap<VPBasicBlock *, VPValue *>;
+ VPPredicator(BlockMaskCacheTy &BlockMaskCache)
+ : BlockMaskCache(BlockMaskCache) {}
+
+ /// Builder to construct recipes to compute masks.
+ VPBuilder Builder;
+
+ /// When we if-convert we need to create edge masks. We have to cache values
+ /// so that we don't end up with exponential recursion/IR.
+ using EdgeMaskCacheTy =
+ DenseMap<std::pair<const VPBasicBlock *, const VPBasicBlock *>,
+ VPValue *>;
+ EdgeMaskCacheTy EdgeMaskCache;
+
+ BlockMaskCacheTy &BlockMaskCache;
+
+ /// Returns the previously computed predicate of the edge between \p Src and
+ /// \p Dst.
+ VPValue *getEdgeMask(const VPBasicBlock *Src, const VPBasicBlock *Dst) const {
+ return EdgeMaskCache.lookup({Src, Dst});
+ }
+
+ /// Returns the *entry* mask for \p VPBB.
+ VPValue *getBlockInMask(VPBasicBlock *VPBB) const {
+ return BlockMaskCache.lookup(VPBB);
+ }
----------------
fhahn wrote:
Done thanks
https://github.com/llvm/llvm-project/pull/128420
More information about the llvm-commits
mailing list