[llvm] [VPlan] Refine the constructor of VPWidenIntrinsicRecipe. nfc (PR #113890)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 28 05:23:57 PDT 2024
https://github.com/Mel-Chen updated https://github.com/llvm/llvm-project/pull/113890
>From 4c911e336fcffcafbcd7dd142c0a0b3ed3f81138 Mon Sep 17 00:00:00 2001
From: Mel Chen <mel.chen at sifive.com>
Date: Mon, 28 Oct 2024 02:42:31 -0700
Subject: [PATCH] [VPlan] Refine the constructor of VPWidenIntrinsicRecipe
---
llvm/lib/Transforms/Vectorize/VPlan.h | 17 +++++++++++------
.../Transforms/Vectorize/VPlanTransforms.cpp | 2 +-
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index a34e34a0d71f1e..b2190406861893 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1688,13 +1688,18 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags {
VPWidenIntrinsicRecipe(Intrinsic::ID VectorIntrinsicID,
ArrayRef<VPValue *> CallArguments, Type *Ty,
- bool MayReadFromMemory, bool MayWriteToMemory,
- bool MayHaveSideEffects, DebugLoc DL = {})
+ DebugLoc DL = {})
: VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments),
- VectorIntrinsicID(VectorIntrinsicID), ResultTy(Ty),
- MayReadFromMemory(MayReadFromMemory),
- MayWriteToMemory(MayWriteToMemory),
- MayHaveSideEffects(MayHaveSideEffects) {}
+ VectorIntrinsicID(VectorIntrinsicID), ResultTy(Ty) {
+ LLVMContext &Ctx = Ty->getContext();
+ AttributeList Attrs = Intrinsic::getAttributes(Ctx, VectorIntrinsicID);
+ MemoryEffects ME = Attrs.getMemoryEffects();
+ MayReadFromMemory = ME.onlyWritesMemory();
+ MayWriteToMemory = ME.onlyReadsMemory();
+ MayHaveSideEffects = MayWriteToMemory ||
+ Attrs.hasFnAttr(Attribute::NoUnwind) ||
+ !Attrs.hasFnAttr(Attribute::WillReturn);
+ }
~VPWidenIntrinsicRecipe() override = default;
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 03c4110761ac6a..355781f955052e 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1489,7 +1489,7 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
Ops.push_back(&EVL);
return new VPWidenIntrinsicRecipe(Intrinsic::vp_select, Ops,
TypeInfo.inferScalarType(Sel),
- false, false, false);
+ Sel->getDebugLoc());
})
.Default([&](VPRecipeBase *R) { return nullptr; });
More information about the llvm-commits
mailing list