Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/lib/Analysis/InlineCost.cpp
Show First 20 Lines • Show All 267 Lines • ▼ Show 20 Lines | class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> { | ||||
bool visitBitCast(BitCastInst &I); | bool visitBitCast(BitCastInst &I); | ||||
bool visitPtrToInt(PtrToIntInst &I); | bool visitPtrToInt(PtrToIntInst &I); | ||||
bool visitIntToPtr(IntToPtrInst &I); | bool visitIntToPtr(IntToPtrInst &I); | ||||
bool visitCastInst(CastInst &I); | bool visitCastInst(CastInst &I); | ||||
bool visitUnaryInstruction(UnaryInstruction &I); | bool visitUnaryInstruction(UnaryInstruction &I); | ||||
bool visitCmpInst(CmpInst &I); | bool visitCmpInst(CmpInst &I); | ||||
bool visitSub(BinaryOperator &I); | bool visitSub(BinaryOperator &I); | ||||
bool visitBinaryOperator(BinaryOperator &I); | bool visitBinaryOperator(BinaryOperator &I); | ||||
bool visitFNeg(UnaryOperator &I); | |||||
bool visitLoad(LoadInst &I); | bool visitLoad(LoadInst &I); | ||||
bool visitStore(StoreInst &I); | bool visitStore(StoreInst &I); | ||||
bool visitExtractValue(ExtractValueInst &I); | bool visitExtractValue(ExtractValueInst &I); | ||||
bool visitInsertValue(InsertValueInst &I); | bool visitInsertValue(InsertValueInst &I); | ||||
bool visitCallBase(CallBase &Call); | bool visitCallBase(CallBase &Call); | ||||
bool visitReturnInst(ReturnInst &RI); | bool visitReturnInst(ReturnInst &RI); | ||||
bool visitBranchInst(BranchInst &BI); | bool visitBranchInst(BranchInst &BI); | ||||
bool visitSelectInst(SelectInst &SI); | bool visitSelectInst(SelectInst &SI); | ||||
▲ Show 20 Lines • Show All 817 Lines • ▼ Show 20 Lines | bool CallAnalyzer::visitBinaryOperator(BinaryOperator &I) { | ||||
if (I.getType()->isFloatingPointTy() && | if (I.getType()->isFloatingPointTy() && | ||||
TTI.getFPOpCost(I.getType()) == TargetTransformInfo::TCC_Expensive && | TTI.getFPOpCost(I.getType()) == TargetTransformInfo::TCC_Expensive && | ||||
!match(&I, m_FNeg(m_Value()))) | !match(&I, m_FNeg(m_Value()))) | ||||
addCost(InlineConstants::CallPenalty); | addCost(InlineConstants::CallPenalty); | ||||
return false; | return false; | ||||
} | } | ||||
bool CallAnalyzer::visitFNeg(UnaryOperator &I) { | |||||
Value *Op = I.getOperand(0); | |||||
Constant *COp = dyn_cast<Constant>(Op); | |||||
if (!COp) | |||||
COp = SimplifiedValues.lookup(Op); | |||||
Value *SimpleV = SimplifyFNegInst(COp ? COp : Op, | |||||
cast<FPMathOperator>(I).getFastMathFlags(), | |||||
DL); | |||||
if (Constant *C = dyn_cast_or_null<Constant>(SimpleV)) | |||||
SimplifiedValues[&I] = C; | |||||
if (SimpleV) | |||||
return true; | |||||
// Disable any SROA on arguments to arbitrary, unsimplified fneg. | |||||
disableSROA(Op); | |||||
return false; | |||||
} | |||||
bool CallAnalyzer::visitLoad(LoadInst &I) { | bool CallAnalyzer::visitLoad(LoadInst &I) { | ||||
Value *SROAArg; | Value *SROAArg; | ||||
DenseMap<Value *, int>::iterator CostIt; | DenseMap<Value *, int>::iterator CostIt; | ||||
if (lookupSROAArgAndCost(I.getPointerOperand(), SROAArg, CostIt)) { | if (lookupSROAArgAndCost(I.getPointerOperand(), SROAArg, CostIt)) { | ||||
if (I.isSimple()) { | if (I.isSimple()) { | ||||
accumulateSROACost(CostIt, InlineConstants::InstrCost); | accumulateSROACost(CostIt, InlineConstants::InstrCost); | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,104 Lines • Show Last 20 Lines |