[llvm] [LV] Add a unittest to a failing scenario that should succeed (PR #196722)
Hassnaa Hamdi via llvm-commits
llvm-commits at lists.llvm.org
Sat May 9 06:18:22 PDT 2026
https://github.com/hassnaaHamdi created https://github.com/llvm/llvm-project/pull/196722
None
>From c5b62e98055e0f4e8772b78e53c5fb98ce079cb8 Mon Sep 17 00:00:00 2001
From: Hassnaa Hamdi <hassnaa.hamdi at arm.com>
Date: Sat, 9 May 2026 13:12:33 +0000
Subject: [PATCH] [LV] Add a unittest to a failing scenario that should succeed
---
.../Transforms/Vectorize/VPlanTest.cpp | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
index a1ddda7eda969..cfeeebaa3764f 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -1804,5 +1804,39 @@ TEST_F(VPInstructionTest, VPSymbolicValueAddUserAfterMaterialization) {
}
#endif
+TEST_F(VPRecipeTest, UFAddUsersBeforeMaterialization) {
+ VPlan &Plan = getPlan();
+ VPBasicBlock *Header = Plan.createVPBasicBlock("vector.header");
+ VPBasicBlock *Latch = Plan.createVPBasicBlock("vector.latch");
+ VPRegionBlock *LoopRegion = Plan.createLoopRegion(
+ Type::getInt32Ty(C), DebugLoc(), "vector.loop", Header, Latch);
+ VPBlockUtils::connectBlocks(Header, Latch);
+ VPBlockUtils::connectBlocks(Plan.getEntry(), LoopRegion);
+ VPBlockUtils::connectBlocks(LoopRegion, Plan.getScalarHeader());
+
+ auto *VScale = new VPInstruction(VPInstruction::VScale, {});
+ Plan.getVectorPreheader()->appendRecipe(VScale);
+
+ VPValue *UF = &Plan.getUF();
+ auto *Step =
+ new VPInstruction(Instruction::Mul, {VScale, UF},
+ VPIRFlags(VPIRFlags::WrapFlagsTy(false, false)));
+ Plan.getVectorPreheader()->appendRecipe(Step);
+
+ auto *Increment = new VPInstruction(
+ Instruction::Add, {LoopRegion->getCanonicalIV(), Step},
+ VPIRFlags(VPIRFlags::WrapFlagsTy(LoopRegion->hasCanonicalIVNUW(), false)),
+ {}, DebugLoc(), "index.next");
+ Latch->appendRecipe(Increment);
+
+ auto *Br = new VPInstruction(VPInstruction::BranchOnCount,
+ {Increment, &Plan.getVectorTripCount()});
+ Latch->appendRecipe(Br);
+
+ Plan.getVFxUF().markMaterialized();
+ Plan.dump();
+ EXPECT_EQ(Increment, LoopRegion->getOrCreateCanonicalIVIncrement());
+}
+
} // namespace
} // namespace llvm
More information about the llvm-commits
mailing list