[llvm] [InjectTLIMappings] Remove signext/zeroext attributes from vector functions. (PR #80546)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 3 07:22:10 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Yeting Kuo (yetingk)
<details>
<summary>Changes</summary>
Previously, when declaring vector functions, its attributes are copied by its scalar function. It may be illegal, since signext/zeroext could not be used for vector types.
---
Full diff: https://github.com/llvm/llvm-project/pull/80546.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Utils/InjectTLIMappings.cpp (+15)
``````````diff
diff --git a/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp b/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
index 9bfac2ac9167e..27bfee4dfc7a9 100644
--- a/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
+++ b/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
@@ -34,6 +34,19 @@ STATISTIC(NumVFDeclAdded,
STATISTIC(NumCompUsedAdded,
"Number of `@llvm.compiler.used` operands that have been added.");
+static void removeIllegalAttributes(Function *Func, const FunctionType *FTy) {
+ // Vector types could not have attributes signext/zeroext.
+ if (FTy->getReturnType()->isVectorTy()) {
+ Func->removeRetAttr(Attribute::SExt);
+ Func->removeRetAttr(Attribute::ZExt);
+ }
+ for (const auto I : enumerate(FTy->params()))
+ if (I.value()->isVectorTy()) {
+ Func->removeParamAttr(I.index(), Attribute::SExt);
+ Func->removeParamAttr(I.index(), Attribute::ZExt);
+ }
+}
+
/// A helper function that adds the vector variant declaration for vectorizing
/// the CallInst \p CI with a vectorization factor of \p VF lanes. For each
/// mapping, TLI provides a VABI prefix, which contains all information required
@@ -56,6 +69,8 @@ static void addVariantDeclaration(CallInst &CI, const ElementCount &VF,
Function *VecFunc =
Function::Create(VectorFTy, Function::ExternalLinkage, VFName, M);
VecFunc->copyAttributesFrom(CI.getCalledFunction());
+ removeIllegalAttributes(VecFunc, VectorFTy);
+
++NumVFDeclAdded;
LLVM_DEBUG(dbgs() << DEBUG_TYPE << ": Added to the module: `" << VFName
<< "` of type " << *VectorFTy << "\n");
``````````
</details>
https://github.com/llvm/llvm-project/pull/80546
More information about the llvm-commits
mailing list