[llvm] [VPlan] Use vputils::getOpcode in poisonGuaranteesUB (NFC) (PR #215750)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 12 00:46:52 PDT 2026
https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/215750
None
>From 0bfe3defc06dfdad4538bef1bccba43efc4d2e51 Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <artagnon at tenstorrent.com>
Date: Wed, 12 Aug 2026 08:45:05 +0100
Subject: [PATCH] [VPlan] Use vputils::getOpcode in poisonGuaranteesUB (NFC)
---
llvm/lib/Transforms/Vectorize/VPlanUtils.cpp | 27 ++++++++------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
index e450b08edfb97..4e9d683cfa99a 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
@@ -59,26 +59,19 @@ VPValue *vputils::getOrCreateVPValueForSCEVExpr(VPlan &Plan, const SCEV *Expr) {
return Expanded;
}
-/// Returns true if \p R propagates poison from any operand to its result.
-static bool propagatesPoisonFromRecipeOp(const VPRecipeBase *R) {
- return TypeSwitch<const VPRecipeBase *, bool>(R)
- .Case<VPWidenGEPRecipe, VPWidenCastRecipe>(
- [](const VPRecipeBase *) { return true; })
- .Case([](const VPReplicateRecipe *Rep) {
- // GEP and casts propagate poison from all operands.
- unsigned Opcode = Rep->getOpcode();
- return Opcode == Instruction::GetElementPtr ||
- Instruction::isCast(Opcode);
- })
- .Default([](const VPRecipeBase *) { return false; });
-}
-
/// Returns true if \p V being poison is guaranteed to trigger UB because it
/// propagates to the address of a memory recipe.
static bool poisonGuaranteesUB(const VPValue *V) {
SmallPtrSet<const VPValue *, 8> Visited;
SmallVector<const VPValue *, 16> Worklist;
+ auto PropagatesPoisonFromRecipeOp = [](const VPRecipeBase *R) {
+ if (!isa<VPSingleDefRecipe>(R))
+ return false;
+ unsigned Opcode = vputils::getOpcode(R->getVPSingleValue());
+ return Instruction::isCast(Opcode) || Opcode == Instruction::GetElementPtr;
+ };
+
Worklist.push_back(V);
while (!Worklist.empty()) {
@@ -88,7 +81,8 @@ static bool poisonGuaranteesUB(const VPValue *V) {
for (VPUser *U : Current->users()) {
// Check if Current is used as an address operand for load/store.
- if (auto *MemR = dyn_cast<VPWidenMemoryRecipe>(cast<VPRecipeBase>(U))) {
+ auto *R = cast<VPRecipeBase>(U);
+ if (auto *MemR = dyn_cast<VPWidenMemoryRecipe>(R)) {
if (MemR->getAddr() == Current)
return true;
continue;
@@ -101,9 +95,8 @@ static bool poisonGuaranteesUB(const VPValue *V) {
}
// Check if poison propagates through this recipe to any of its users.
- auto *R = cast<VPRecipeBase>(U);
for (const VPValue *Op : R->operands()) {
- if (Op == Current && propagatesPoisonFromRecipeOp(R)) {
+ if (Op == Current && PropagatesPoisonFromRecipeOp(R)) {
Worklist.push_back(R->getVPSingleValue());
break;
}
More information about the llvm-commits
mailing list