[llvm] c612c98 - [VPlan] Add const to VPPredicator methods. nfc (#184359)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 23:53:17 PST 2026
Author: Mel Chen
Date: 2026-03-04T15:53:13+08:00
New Revision: c612c98fa6dc613ebc1350cc1d87c8cd5d840428
URL: https://github.com/llvm/llvm-project/commit/c612c98fa6dc613ebc1350cc1d87c8cd5d840428
DIFF: https://github.com/llvm/llvm-project/commit/c612c98fa6dc613ebc1350cc1d87c8cd5d840428.diff
LOG: [VPlan] Add const to VPPredicator methods. nfc (#184359)
Add const to VPBasicBlock pointer parameters and cache key types where
the blocks are not modified.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp b/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp
index ad4fd69882f30..1ab29d5140661 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp
@@ -32,21 +32,21 @@ class VPPredicator {
using EdgeMaskCacheTy =
DenseMap<std::pair<const VPBasicBlock *, const VPBasicBlock *>,
VPValue *>;
- using BlockMaskCacheTy = DenseMap<VPBasicBlock *, VPValue *>;
+ using BlockMaskCacheTy = DenseMap<const VPBasicBlock *, VPValue *>;
EdgeMaskCacheTy EdgeMaskCache;
BlockMaskCacheTy BlockMaskCache;
/// Create an edge mask for every destination of cases and/or default.
- void createSwitchEdgeMasks(VPInstruction *SI);
+ void createSwitchEdgeMasks(const VPInstruction *SI);
/// Computes and return the predicate of the edge between \p Src and \p Dst,
/// possibly inserting new recipes at \p Dst (using Builder's insertion point)
- VPValue *createEdgeMask(VPBasicBlock *Src, VPBasicBlock *Dst);
+ VPValue *createEdgeMask(const VPBasicBlock *Src, const VPBasicBlock *Dst);
/// Record \p Mask as the *entry* mask of \p VPBB, which is expected to not
/// already have a mask.
- void setBlockInMask(VPBasicBlock *VPBB, VPValue *Mask) {
+ void setBlockInMask(const VPBasicBlock *VPBB, VPValue *Mask) {
// TODO: Include the masks as operands in the predicated VPlan directly to
// avoid keeping the map of masks beyond the predication transform.
assert(!getBlockInMask(VPBB) && "Mask already set");
@@ -64,7 +64,7 @@ class VPPredicator {
public:
/// Returns the *entry* mask for \p VPBB.
- VPValue *getBlockInMask(VPBasicBlock *VPBB) const {
+ VPValue *getBlockInMask(const VPBasicBlock *VPBB) const {
return BlockMaskCache.lookup(VPBB);
}
@@ -85,7 +85,8 @@ class VPPredicator {
};
} // namespace
-VPValue *VPPredicator::createEdgeMask(VPBasicBlock *Src, VPBasicBlock *Dst) {
+VPValue *VPPredicator::createEdgeMask(const VPBasicBlock *Src,
+ const VPBasicBlock *Dst) {
assert(is_contained(Dst->getPredecessors(), Src) && "Invalid edge");
// Look for cached value.
@@ -175,8 +176,8 @@ void VPPredicator::createHeaderMask(VPBasicBlock *HeaderVPBB, bool FoldTail) {
setBlockInMask(HeaderVPBB, BlockMask);
}
-void VPPredicator::createSwitchEdgeMasks(VPInstruction *SI) {
- VPBasicBlock *Src = SI->getParent();
+void VPPredicator::createSwitchEdgeMasks(const VPInstruction *SI) {
+ const VPBasicBlock *Src = SI->getParent();
// Create masks where SI is a switch. We create masks for all edges from SI's
// parent block at the same time. This is more efficient, as we can create and
More information about the llvm-commits
mailing list