LLVM  14.0.0git
Functions | Variables
SimplifyLibCalls.cpp File Reference
#include "llvm/Transforms/Utils/SimplifyLibCalls.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Analysis/CaptureTracking.h"
#include "llvm/Analysis/Loads.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Transforms/Utils/BuildLibCalls.h"
#include "llvm/Transforms/Utils/SizeOpts.h"
Include dependency graph for SimplifyLibCalls.cpp:

Go to the source code of this file.

Functions

static bool ignoreCallingConv (LibFunc Func)
 
static bool isOnlyUsedInEqualityComparison (Value *V, Value *With)
 Return true if it is only used in equality comparisons with With. More...
 
static bool callHasFloatingPointArgument (const CallInst *CI)
 
static bool callHasFP128Argument (const CallInst *CI)
 
static ValueconvertStrToNumber (CallInst *CI, StringRef &Str, int64_t Base)
 
static bool isOnlyUsedInComparisonWithZero (Value *V)
 
static bool canTransformToMemCmp (CallInst *CI, Value *Str, uint64_t Len, const DataLayout &DL)
 
static void annotateDereferenceableBytes (CallInst *CI, ArrayRef< unsigned > ArgNos, uint64_t DereferenceableBytes)
 
static void annotateNonNullNoUndefBasedOnAccess (CallInst *CI, ArrayRef< unsigned > ArgNos)
 
static void annotateNonNullAndDereferenceable (CallInst *CI, ArrayRef< unsigned > ArgNos, Value *Size, const DataLayout &DL)
 
static ValueoptimizeMemCmpConstantSize (CallInst *CI, Value *LHS, Value *RHS, uint64_t Len, IRBuilderBase &B, const DataLayout &DL)
 
static ValuereplaceUnaryCall (CallInst *CI, IRBuilderBase &B, Intrinsic::ID IID)
 
static ValuevalueHasFloatPrecision (Value *Val)
 Return a variant of Val with float type. More...
 
static ValueoptimizeDoubleFP (CallInst *CI, IRBuilderBase &B, bool isBinary, bool isPrecise=false)
 Shrink double -> float functions. More...
 
static ValueoptimizeUnaryDoubleFP (CallInst *CI, IRBuilderBase &B, bool isPrecise=false)
 Shrink double -> float for unary functions. More...
 
static ValueoptimizeBinaryDoubleFP (CallInst *CI, IRBuilderBase &B, bool isPrecise=false)
 Shrink double -> float for binary functions. More...
 
static ValueoptimizeTrigReflections (CallInst *Call, LibFunc Func, IRBuilderBase &B)
 
static ValuegetPow (Value *InnerChain[33], unsigned Exp, IRBuilderBase &B)
 
static ValuegetIntToFPVal (Value *I2F, IRBuilderBase &B, unsigned DstWidth)
 
static ValuegetSqrtCall (Value *V, AttributeList Attrs, bool NoErrno, Module *M, IRBuilderBase &B, const TargetLibraryInfo *TLI)
 
static ValuecreatePowWithIntegerExponent (Value *Base, Value *Expo, Module *M, IRBuilderBase &B)
 
static bool isTrigLibCall (CallInst *CI)
 
static void insertSinCosCall (IRBuilderBase &B, Function *OrigCallee, Value *Arg, bool UseFloat, Value *&Sin, Value *&Cos, Value *&SinCos)
 
static bool isReportingError (Function *Callee, CallInst *CI, int StreamArg)
 

Variables

static cl::opt< bool > EnableUnsafeFPShrink ("enable-double-float-shrink", cl::Hidden, cl::init(false), cl::desc("Enable unsafe double to float " "shrinking for math lib calls"))
 

Function Documentation

◆ annotateDereferenceableBytes()

static void annotateDereferenceableBytes ( CallInst CI,
ArrayRef< unsigned >  ArgNos,
uint64_t  DereferenceableBytes 
)
static

◆ annotateNonNullAndDereferenceable()

static void annotateNonNullAndDereferenceable ( CallInst CI,
ArrayRef< unsigned >  ArgNos,
Value Size,
const DataLayout DL 
)
static

◆ annotateNonNullNoUndefBasedOnAccess()

static void annotateNonNullNoUndefBasedOnAccess ( CallInst CI,
ArrayRef< unsigned >  ArgNos 
)
static

◆ callHasFloatingPointArgument()

static bool callHasFloatingPointArgument ( const CallInst CI)
static

Definition at line 71 of file SimplifyLibCalls.cpp.

References llvm::any_of(), and llvm::User::operands().

◆ callHasFP128Argument()

static bool callHasFP128Argument ( const CallInst CI)
static

Definition at line 77 of file SimplifyLibCalls.cpp.

References llvm::any_of(), and llvm::User::operands().

◆ canTransformToMemCmp()

static bool canTransformToMemCmp ( CallInst CI,
Value Str,
uint64_t  Len,
const DataLayout DL 
)
static

◆ convertStrToNumber()

static Value* convertStrToNumber ( CallInst CI,
StringRef Str,
int64_t  Base 
)
static

Definition at line 83 of file SimplifyLibCalls.cpp.

References llvm::sampleprof::Base.

◆ createPowWithIntegerExponent()

static Value* createPowWithIntegerExponent ( Value Base,
Value Expo,
Module M,
IRBuilderBase B 
)
static

◆ getIntToFPVal()

static Value* getIntToFPVal ( Value I2F,
IRBuilderBase B,
unsigned  DstWidth 
)
static

Definition at line 1379 of file SimplifyLibCalls.cpp.

References B, and llvm::BitWidth.

◆ getPow()

static Value* getPow ( Value InnerChain[33],
unsigned  Exp,
IRBuilderBase B 
)
static

Definition at line 1352 of file SimplifyLibCalls.cpp.

References assert(), and B.

◆ getSqrtCall()

static Value* getSqrtCall ( Value V,
AttributeList  Attrs,
bool  NoErrno,
Module M,
IRBuilderBase B,
const TargetLibraryInfo TLI 
)
static

◆ ignoreCallingConv()

static bool ignoreCallingConv ( LibFunc  Func)
static

◆ insertSinCosCall()

static void insertSinCosCall ( IRBuilderBase B,
Function OrigCallee,
Value Arg,
bool  UseFloat,
Value *&  Sin,
Value *&  Cos,
Value *&  SinCos 
)
static

◆ isOnlyUsedInComparisonWithZero()

static bool isOnlyUsedInComparisonWithZero ( Value V)
static

Definition at line 108 of file SimplifyLibCalls.cpp.

References llvm::Value::users().

Referenced by canTransformToMemCmp().

◆ isOnlyUsedInEqualityComparison()

static bool isOnlyUsedInEqualityComparison ( Value V,
Value With 
)
static

Return true if it is only used in equality comparisons with With.

Definition at line 60 of file SimplifyLibCalls.cpp.

References llvm::Value::users().

◆ isReportingError()

static bool isReportingError ( Function Callee,
CallInst CI,
int  StreamArg 
)
static

◆ isTrigLibCall()

static bool isTrigLibCall ( CallInst CI)
static

Definition at line 2048 of file SimplifyLibCalls.cpp.

References llvm::CallBase::hasFnAttr().

◆ optimizeBinaryDoubleFP()

static Value* optimizeBinaryDoubleFP ( CallInst CI,
IRBuilderBase B,
bool  isPrecise = false 
)
static

Shrink double -> float for binary functions.

Definition at line 1283 of file SimplifyLibCalls.cpp.

References B, and optimizeDoubleFP().

◆ optimizeDoubleFP()

static Value* optimizeDoubleFP ( CallInst CI,
IRBuilderBase B,
bool  isBinary,
bool  isPrecise = false 
)
static

◆ optimizeMemCmpConstantSize()

static Value* optimizeMemCmpConstantSize ( CallInst CI,
Value LHS,
Value RHS,
uint64_t  Len,
IRBuilderBase B,
const DataLayout DL 
)
static

◆ optimizeTrigReflections()

static Value* optimizeTrigReflections ( CallInst Call,
LibFunc  Func,
IRBuilderBase B 
)
static

◆ optimizeUnaryDoubleFP()

static Value* optimizeUnaryDoubleFP ( CallInst CI,
IRBuilderBase B,
bool  isPrecise = false 
)
static

Shrink double -> float for unary functions.

Definition at line 1277 of file SimplifyLibCalls.cpp.

References B, and optimizeDoubleFP().

◆ replaceUnaryCall()

static Value* replaceUnaryCall ( CallInst CI,
IRBuilderBase B,
Intrinsic::ID  IID 
)
static

◆ valueHasFloatPrecision()

static Value* valueHasFloatPrecision ( Value Val)
static

Return a variant of Val with float type.

Currently this works in two cases: If Val is an FPExtension of a float value to something bigger, simply return the operand. If Val is a ConstantFP but can be converted to a float ConstantFP without loss of precision do so.

Definition at line 1201 of file SimplifyLibCalls.cpp.

References F, llvm::ConstantFP::get(), llvm::APFloatBase::IEEEsingle(), and llvm::APFloatBase::rmNearestTiesToEven.

Referenced by optimizeDoubleFP().

Variable Documentation

◆ EnableUnsafeFPShrink

cl::opt<bool> EnableUnsafeFPShrink("enable-double-float-shrink", cl::Hidden, cl::init(false), cl::desc("Enable unsafe double to float " "shrinking for math lib calls"))
static