[llvm] [VPlan] Refine the constructor of VPWidenIntrinsicRecipe. nfc (PR #113890)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 28 02:46:12 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-vectorizers
Author: Mel Chen (Mel-Chen)
<details>
<summary>Changes</summary>
Based on #<!-- -->113887
---
Full diff: https://github.com/llvm/llvm-project/pull/113890.diff
3 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+1-2)
- (modified) llvm/lib/Transforms/Vectorize/VPlan.h (+14-10)
- (modified) llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp (+2-3)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 88086f24dfdce2..a370a8b728be27 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8430,8 +8430,7 @@ VPSingleDefRecipe *VPRecipeBuilder::tryToWidenCall(CallInst *CI,
},
Range);
if (ShouldUseVectorIntrinsic)
- return new VPWidenIntrinsicRecipe(*CI, ID, Ops, CI->getType(),
- CI->getDebugLoc());
+ return new VPWidenIntrinsicRecipe(*CI, ID, Ops, CI->getType());
Function *Variant = nullptr;
std::optional<unsigned> MaskPos;
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index a34e34a0d71f1e..9220ea91b968c5 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1678,8 +1678,7 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags {
public:
VPWidenIntrinsicRecipe(CallInst &CI, Intrinsic::ID VectorIntrinsicID,
- ArrayRef<VPValue *> CallArguments, Type *Ty,
- DebugLoc DL = {})
+ ArrayRef<VPValue *> CallArguments, Type *Ty)
: VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments, CI),
VectorIntrinsicID(VectorIntrinsicID), ResultTy(Ty),
MayReadFromMemory(CI.mayReadFromMemory()),
@@ -1688,20 +1687,25 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags {
VPWidenIntrinsicRecipe(Intrinsic::ID VectorIntrinsicID,
ArrayRef<VPValue *> CallArguments, Type *Ty,
- bool MayReadFromMemory, bool MayWriteToMemory,
- bool MayHaveSideEffects, DebugLoc DL = {})
- : VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments),
- VectorIntrinsicID(VectorIntrinsicID), ResultTy(Ty),
- MayReadFromMemory(MayReadFromMemory),
- MayWriteToMemory(MayWriteToMemory),
- MayHaveSideEffects(MayHaveSideEffects) {}
+ DebugLoc DL = {})
+ : VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments, DL),
+ 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;
VPWidenIntrinsicRecipe *clone() override {
return new VPWidenIntrinsicRecipe(*cast<CallInst>(getUnderlyingValue()),
VectorIntrinsicID, {op_begin(), op_end()},
- ResultTy, getDebugLoc());
+ ResultTy);
}
VP_CLASSOF_IMPL(VPDef::VPWidenIntrinsicSC)
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 03c4110761ac6a..24c459bb817da7 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -84,8 +84,7 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
} else if (CallInst *CI = dyn_cast<CallInst>(Inst)) {
NewRecipe = new VPWidenIntrinsicRecipe(
*CI, getVectorIntrinsicIDForCall(CI, &TLI),
- {Ingredient.op_begin(), Ingredient.op_end() - 1}, CI->getType(),
- CI->getDebugLoc());
+ {Ingredient.op_begin(), Ingredient.op_end() - 1}, CI->getType());
} else if (SelectInst *SI = dyn_cast<SelectInst>(Inst)) {
NewRecipe = new VPWidenSelectRecipe(*SI, Ingredient.operands());
} else if (auto *CI = dyn_cast<CastInst>(Inst)) {
@@ -1489,7 +1488,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; });
``````````
</details>
https://github.com/llvm/llvm-project/pull/113890
More information about the llvm-commits
mailing list