aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/CostModel.cpp24
-rw-r--r--lib/Analysis/TargetTransformInfo.cpp9
2 files changed, 29 insertions, 4 deletions
diff --git a/lib/Analysis/CostModel.cpp b/lib/Analysis/CostModel.cpp
index df70d157b4..98a7780ad9 100644
--- a/lib/Analysis/CostModel.cpp
+++ b/lib/Analysis/CostModel.cpp
@@ -88,6 +88,23 @@ static bool isReverseVectorMask(SmallVector<int, 16> &Mask) {
return true;
}
+static TargetTransformInfo::OperandValueKind getOperandInfo(Value *V) {
+ TargetTransformInfo::OperandValueKind OpInfo =
+ TargetTransformInfo::OK_AnyValue;
+
+ // Check for a splat of a constant.
+ ConstantDataVector *CDV = 0;
+ if ((CDV = dyn_cast<ConstantDataVector>(V)))
+ if (CDV->getSplatValue() != NULL)
+ OpInfo = TargetTransformInfo::OK_UniformConstantValue;
+ ConstantVector *CV = 0;
+ if ((CV = dyn_cast<ConstantVector>(V)))
+ if (CV->getSplatValue() != NULL)
+ OpInfo = TargetTransformInfo::OK_UniformConstantValue;
+
+ return OpInfo;
+}
+
unsigned CostModelAnalysis::getInstructionCost(const Instruction *I) const {
if (!TTI)
return -1;
@@ -121,7 +138,12 @@ unsigned CostModelAnalysis::getInstructionCost(const Instruction *I) const {
case Instruction::And:
case Instruction::Or:
case Instruction::Xor: {
- return TTI->getArithmeticInstrCost(I->getOpcode(), I->getType());
+ TargetTransformInfo::OperandValueKind Op1VK =
+ getOperandInfo(I->getOperand(0));
+ TargetTransformInfo::OperandValueKind Op2VK =
+ getOperandInfo(I->getOperand(1));
+ return TTI->getArithmeticInstrCost(I->getOpcode(), I->getType(), Op1VK,
+ Op2VK);
}
case Instruction::Select: {
const SelectInst *SI = cast<SelectInst>(I);
diff --git a/lib/Analysis/TargetTransformInfo.cpp b/lib/Analysis/TargetTransformInfo.cpp
index 976cd87321..64f8e96884 100644
--- a/lib/Analysis/TargetTransformInfo.cpp
+++ b/lib/Analysis/TargetTransformInfo.cpp
@@ -150,8 +150,10 @@ unsigned TargetTransformInfo::getMaximumUnrollFactor() const {
}
unsigned TargetTransformInfo::getArithmeticInstrCost(unsigned Opcode,
- Type *Ty) const {
- return PrevTTI->getArithmeticInstrCost(Opcode, Ty);
+ Type *Ty,
+ OperandValueKind Op1Info,
+ OperandValueKind Op2Info) const {
+ return PrevTTI->getArithmeticInstrCost(Opcode, Ty, Op1Info, Op2Info);
}
unsigned TargetTransformInfo::getShuffleCost(ShuffleKind Kind, Type *Tp,
@@ -495,7 +497,8 @@ struct NoTTI : ImmutablePass, TargetTransformInfo {
return 1;
}
- unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty) const {
+ unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, OperandValueKind,
+ OperandValueKind) const {
return 1;
}