X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FAnalysis%2FTargetTransformInfoImpl.h;h=43815234051e1ffab16ad536d4f892d6610d8f10;hb=HEAD;hp=e903679259fc289a0f5f477f7afa7abdfda4a3bb;hpb=52aa6d3b71c9b16b2a7aba516a3378a9713e43a2;p=oota-llvm.git diff --git a/include/llvm/Analysis/TargetTransformInfoImpl.h b/include/llvm/Analysis/TargetTransformInfoImpl.h index e903679259f..43815234051 100644 --- a/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -22,6 +22,7 @@ #include "llvm/IR/GetElementPtrTypeIterator.h" #include "llvm/IR/Operator.h" #include "llvm/IR/Type.h" +#include "llvm/Analysis/VectorUtils.h" namespace llvm { @@ -61,6 +62,14 @@ public: // Otherwise, the default basic cost is used. return TTI::TCC_Basic; + case Instruction::FDiv: + case Instruction::FRem: + case Instruction::SDiv: + case Instruction::SRem: + case Instruction::UDiv: + case Instruction::URem: + return TTI::TCC_Expensive; + case Instruction::IntToPtr: { // An inttoptr cast is free so long as the input is a legal integer type // which doesn't contain values outside the range of a pointer. @@ -139,9 +148,6 @@ public: case Intrinsic::objectsize: case Intrinsic::ptr_annotation: case Intrinsic::var_annotation: - case Intrinsic::experimental_gc_result_int: - case Intrinsic::experimental_gc_result_float: - case Intrinsic::experimental_gc_result_ptr: case Intrinsic::experimental_gc_result: case Intrinsic::experimental_gc_relocate: // These intrinsics don't actually represent code after lowering. @@ -201,9 +207,13 @@ public: return !BaseGV && BaseOffset == 0 && (Scale == 0 || Scale == 1); } - bool isLegalMaskedStore(Type *DataType, int Consecutive) { return false; } + bool isLegalMaskedStore(Type *DataType) { return false; } + + bool isLegalMaskedLoad(Type *DataType) { return false; } + + bool isLegalMaskedScatter(Type *DataType) { return false; } - bool isLegalMaskedLoad(Type *DataType, int Consecutive) { return false; } + bool isLegalMaskedGather(Type *DataType) { return false; } int getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace) { @@ -216,8 +226,6 @@ public: bool isTruncateFree(Type *Ty1, Type *Ty2) { return false; } - bool isZExtFree(Type *Ty1, Type *Ty2) { return false; } - bool isProfitableToHoist(Instruction *I) { return true; } bool isTypeLegal(Type *Ty) { return false; } @@ -293,6 +301,12 @@ public: return 1; } + unsigned getGatherScatterOpCost(unsigned Opcode, Type *DataTy, Value *Ptr, + bool VariableMask, + unsigned Alignment) { + return 1; + } + unsigned getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef Indices, @@ -305,6 +319,10 @@ public: ArrayRef Tys) { return 1; } + unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, + ArrayRef Args) { + return 1; + } unsigned getCallInstrCost(Function *F, Type *RetTy, ArrayRef Tys) { return 1; @@ -405,21 +423,28 @@ public: (Ptr == nullptr ? 0 : Ptr->getType()->getPointerAddressSpace()); auto GTI = gep_type_begin(PointerType::get(PointeeType, AS), Operands); for (auto I = Operands.begin(); I != Operands.end(); ++I, ++GTI) { + // We assume that the cost of Scalar GEP with constant index and the + // cost of Vector GEP with splat constant index are the same. + const ConstantInt *ConstIdx = dyn_cast(*I); + if (!ConstIdx) + if (auto Splat = getSplatValue(*I)) + ConstIdx = dyn_cast(Splat); if (isa(*GTI)) { int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType()); - if (const ConstantInt *ConstIdx = dyn_cast(*I)) { + if (ConstIdx) BaseOffset += ConstIdx->getSExtValue() * ElementSize; - } else { + else { // Needs scale register. - if (Scale != 0) { + if (Scale != 0) // No addressing mode takes two scale registers. return TTI::TCC_Basic; - } Scale = ElementSize; } } else { StructType *STy = cast(*GTI); - uint64_t Field = cast(*I)->getZExtValue(); + // For structures the index is always splat or scalar constant + assert(ConstIdx && "Unexpected GEP index"); + uint64_t Field = ConstIdx->getZExtValue(); BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field); } }