[llvm] [VPlan] Mark VPCanonicalIVPHI as not reading memory (NFCI). (PR #190338)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 3 05:39:26 PDT 2026
https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/190338
>From 581bf32cde3df513a3326009644f0a7f4782d3cd Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Fri, 3 Apr 2026 13:00:54 +0100
Subject: [PATCH] [VPlan] Mark VPCanonicalIVPHI as not reading memory (NFCI).
The canonical IV does not access any memory. Mark accordingly. This
should be NFC end-to-end.
---
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp | 1 +
llvm/unittests/Transforms/Vectorize/VPlanTest.cpp | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 05a47273b799a..8323d0d8562a4 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -126,6 +126,7 @@ bool VPRecipeBase::mayReadFromMemory() const {
->onlyWritesMemory();
case VPWidenIntrinsicSC:
return cast<VPWidenIntrinsicRecipe>(this)->mayReadFromMemory();
+ case VPCanonicalIVPHISC:
case VPBranchOnMaskSC:
case VPDerivedIVSC:
case VPCurrentIterationPHISC:
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
index c28631a5a3ddb..ec9c904a08b2c 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -1449,6 +1449,13 @@ TEST_F(VPRecipeTest, MayHaveSideEffectsAndMayReadWriteMemory) {
EXPECT_FALSE(Recipe.mayWriteToMemory());
EXPECT_FALSE(Recipe.mayReadOrWriteMemory());
}
+ {
+ VPIRValue *StartV = Plan.getZero(Int32);
+ VPCanonicalIVPHIRecipe Recipe(StartV, {});
+ EXPECT_FALSE(Recipe.mayReadFromMemory());
+ EXPECT_FALSE(Recipe.mayWriteToMemory());
+ EXPECT_FALSE(Recipe.mayReadOrWriteMemory());
+ }
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
More information about the llvm-commits
mailing list