mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[TTI] Move abs/smax/smin/umax/umin cost expansion to ICA getIntrinsicInstrCost variant
This will simplify target overrides, and matches what we do for most integer intrinsic costs.
This commit is contained in:
parent
acc205118e
commit
44836ba0cf
@ -1223,26 +1223,6 @@ public:
|
||||
IntrinsicCostAttributes Attrs(IID, RetTy, Args[0]->getType(), FMF, 1, I);
|
||||
return getIntrinsicInstrCost(Attrs, CostKind);
|
||||
}
|
||||
case Intrinsic::abs:
|
||||
case Intrinsic::smax:
|
||||
case Intrinsic::smin:
|
||||
case Intrinsic::umax:
|
||||
case Intrinsic::umin: {
|
||||
// abs(X) = select(icmp(X,0),X,sub(0,X))
|
||||
// minmax(X,Y) = select(icmp(X,Y),X,Y)
|
||||
Type *CondTy = RetTy->getWithNewBitWidth(1);
|
||||
unsigned Cost = 0;
|
||||
// TODO: Ideally getCmpSelInstrCost would accept an icmp condition code.
|
||||
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, RetTy, CondTy,
|
||||
CostKind);
|
||||
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::Select, RetTy, CondTy,
|
||||
CostKind);
|
||||
// TODO: Should we add an OperandValueProperties::OP_Zero property?
|
||||
if (IID == Intrinsic::abs)
|
||||
Cost += thisT()->getArithmeticInstrCost(
|
||||
BinaryOperator::Sub, RetTy, CostKind, TTI::OK_UniformConstantValue);
|
||||
return Cost;
|
||||
}
|
||||
case Intrinsic::fshl:
|
||||
case Intrinsic::fshr: {
|
||||
const Value *X = Args[0];
|
||||
@ -1475,6 +1455,26 @@ public:
|
||||
VecOpTy, cast<VectorType>(CmpInst::makeCmpResultType(VecOpTy)),
|
||||
/*IsPairwiseForm=*/false,
|
||||
/*IsUnsigned=*/true, CostKind);
|
||||
case Intrinsic::abs:
|
||||
case Intrinsic::smax:
|
||||
case Intrinsic::smin:
|
||||
case Intrinsic::umax:
|
||||
case Intrinsic::umin: {
|
||||
// abs(X) = select(icmp(X,0),X,sub(0,X))
|
||||
// minmax(X,Y) = select(icmp(X,Y),X,Y)
|
||||
Type *CondTy = RetTy->getWithNewBitWidth(1);
|
||||
unsigned Cost = 0;
|
||||
// TODO: Ideally getCmpSelInstrCost would accept an icmp condition code.
|
||||
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, RetTy, CondTy,
|
||||
CostKind);
|
||||
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::Select, RetTy, CondTy,
|
||||
CostKind);
|
||||
// TODO: Should we add an OperandValueProperties::OP_Zero property?
|
||||
if (IID == Intrinsic::abs)
|
||||
Cost += thisT()->getArithmeticInstrCost(
|
||||
BinaryOperator::Sub, RetTy, CostKind, TTI::OK_UniformConstantValue);
|
||||
return Cost;
|
||||
}
|
||||
case Intrinsic::sadd_sat:
|
||||
case Intrinsic::ssub_sat: {
|
||||
Type *CondTy = RetTy->getWithNewBitWidth(1);
|
||||
|
Loading…
Reference in New Issue
Block a user