[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:29:46 PDT 2026
https://github.com/fhahn created https://github.com/llvm/llvm-project/pull/190338
The canonical IV does not access any memory. Mark accordingly. This should be NFC end-to-end.
>From 9a6c84a73868f694758510c0bb3c0ab2c39cb3ec 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 | 8 ++++++++
2 files changed, 9 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..527a2e05fc868 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -1449,6 +1449,14 @@ TEST_F(VPRecipeTest, MayHaveSideEffectsAndMayReadWriteMemory) {
EXPECT_FALSE(Recipe.mayWriteToMemory());
EXPECT_FALSE(Recipe.mayReadOrWriteMemory());
}
+ {
+ VPIRValue *StartV =
+ Plan.getOrAddLiveIn(ConstantInt::get(Int32, 0));
+ 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