Go to the documentation of this file.
30 #define DEBUG_TYPE "replace-with-veclib"
33 "Number of calls to intrinsics that have been replaced.");
36 "Number of vector library function declarations added.");
39 "Number of functions added to `llvm.compiler.used`");
48 Function *TLIFunc =
M->getFunction(TLIName);
55 << TLIName <<
"` of type `" << *(TLIFunc->
getType())
58 ++NumTLIFuncDeclAdded;
65 <<
"` to `@llvm.compiler.used`.\n");
78 "Expecting function types to be identical");
80 if (isa<FPMathOperator>(Replacement)) {
86 << OldFunc->
getName() <<
"` with call to `" << TLIName
109 auto *ArgType =
Arg.value()->getType();
113 ScalarTypes.push_back(ArgType);
117 auto *VectorArgTy = dyn_cast<VectorType>(ArgType);
123 ElementCount NumElements = VectorArgTy->getElementCount();
129 if (VF.
isNonZero() && VF != NumElements) {
135 ScalarTypes.push_back(VectorArgTy->getElementType());
142 std::string ScalarName;
158 const std::string TLIName =
162 << ScalarName <<
"` and vector width " << VF <<
".\n");
164 if (!TLIName.empty()) {
177 bool Changed =
false;
180 if (
auto *CI = dyn_cast<CallInst>(&
I)) {
182 ReplacedCalls.push_back(CI);
189 for (
auto *CI : ReplacedCalls) {
190 CI->eraseFromParent();
222 getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
F);
244 "Replace intrinsics with calls to vector library",
false,
A set of analyses that are preserved following a run of a transformation pass.
bool isOverloaded(ID id)
Returns true if the intrinsic can be overloaded.
Analysis pass that exposes the ScalarEvolution for a function.
This analysis provides dependence information for the memory accesses of a loop.
This is an optimization pass for GlobalISel generic memory operations.
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static bool replaceWithCallToVeclib(const TargetLibraryInfo &TLI, CallInst &CI)
detail::enumerator< R > enumerate(R &&TheRange)
Given an input range, returns a new range whose values are are pair (A,B) such that A is the 0-based ...
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const
bool isVectorIntrinsicWithScalarOpAtArg(Intrinsic::ID ID, unsigned ScalarOpdIdx)
Identifies if the vector form of the intrinsic has a scalar operand.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
This analysis provides dependence information for the memory accesses of a loop.
An analysis that produces DemandedBits for a function.
bool isScalable() const
Returns whether the size is scaled by a runtime quantity (vscale).
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
static bool replaceWithTLIFunction(CallInst &CI, const StringRef TLIName)
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Represent the analysis usage information of a pass.
static bool runImpl(const TargetLibraryInfo &TLI, Function &F)
FunctionPass * createReplaceWithVeclibLegacyPass()
void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.
STATISTIC(NumFunctions, "Total number of functions")
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
static ElementCount getFixed(ScalarTy MinVal)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
inst_range instructions(Function *F)
INITIALIZE_PASS_BEGIN(ReplaceWithVeclibLegacy, DEBUG_TYPE, "Replace intrinsics with calls to vector library", false, false) INITIALIZE_PASS_END(ReplaceWithVeclibLegacy
expand Expand reduction intrinsics
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
void preserve()
Mark an analysis as preserved.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A Module instance is used to store all the information related to an LLVM module.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Replace intrinsics with calls to vector library
void setPreservesCFG()
This function should be called by the pass, iff they do not:
StringRef - Represent a constant reference to a string, i.e.
Represents analyses that only rely on functions' control flow.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction,...
StringRef getName() const
Return a constant reference to the value's name.
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Provides information about what library functions are available for the current target.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
@ ExternalLinkage
Externally visible function.
void preserveSet()
Mark an analysis set as preserved.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
Legacy wrapper pass to provide the GlobalsAAResult object.
amdgpu Simplify well known AMD library calls
PointerType * getType() const
Global values are always pointers.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
This class represents a function call, abstracting a target machine's calling convention.
AnalysisUsage & addRequired()
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Analysis pass providing the TargetLibraryInfo.
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
StringRef getVectorizedFunction(StringRef F, const ElementCount &VF) const