@@ -428,9 +428,9 @@ bool VectorCombine::isExtractExtractCheap(ExtractElementInst *Ext0,
428
428
" Expected a compare" );
429
429
CmpInst::Predicate Pred = cast<CmpInst>(I).getPredicate ();
430
430
ScalarOpCost = TTI.getCmpSelInstrCost (
431
- Opcode, ScalarTy, CmpInst::makeCmpResultType (ScalarTy), Pred);
431
+ Opcode, ScalarTy, CmpInst::makeCmpResultType (ScalarTy), Pred, CostKind );
432
432
VectorOpCost = TTI.getCmpSelInstrCost (
433
- Opcode, VecTy, CmpInst::makeCmpResultType (VecTy), Pred);
433
+ Opcode, VecTy, CmpInst::makeCmpResultType (VecTy), Pred, CostKind );
434
434
}
435
435
436
436
// Get cost estimates for the extract elements. These costs will factor into
@@ -991,9 +991,9 @@ bool VectorCombine::scalarizeBinopOrCmp(Instruction &I) {
991
991
if (IsCmp) {
992
992
CmpInst::Predicate Pred = cast<CmpInst>(I).getPredicate ();
993
993
ScalarOpCost = TTI.getCmpSelInstrCost (
994
- Opcode, ScalarTy, CmpInst::makeCmpResultType (ScalarTy), Pred);
994
+ Opcode, ScalarTy, CmpInst::makeCmpResultType (ScalarTy), Pred, CostKind );
995
995
VectorOpCost = TTI.getCmpSelInstrCost (
996
- Opcode, VecTy, CmpInst::makeCmpResultType (VecTy), Pred);
996
+ Opcode, VecTy, CmpInst::makeCmpResultType (VecTy), Pred, CostKind );
997
997
} else {
998
998
ScalarOpCost = TTI.getArithmeticInstrCost (Opcode, ScalarTy, CostKind);
999
999
VectorOpCost = TTI.getArithmeticInstrCost (Opcode, VecTy, CostKind);
@@ -1093,14 +1093,15 @@ bool VectorCombine::foldExtractedCmps(Instruction &I) {
1093
1093
return false ;
1094
1094
1095
1095
InstructionCost Ext0Cost =
1096
- TTI.getVectorInstrCost (*Ext0, VecTy, CostKind, Index0),
1097
- Ext1Cost =
1098
- TTI.getVectorInstrCost (*Ext1, VecTy, CostKind, Index1);
1096
+ TTI.getVectorInstrCost (*Ext0, VecTy, CostKind, Index0);
1097
+ InstructionCost Ext1Cost =
1098
+ TTI.getVectorInstrCost (*Ext1, VecTy, CostKind, Index1);
1099
+ InstructionCost CmpCost = TTI.getCmpSelInstrCost (
1100
+ CmpOpcode, I0->getType (), CmpInst::makeCmpResultType (I0->getType ()), Pred,
1101
+ CostKind);
1102
+
1099
1103
InstructionCost OldCost =
1100
- Ext0Cost + Ext1Cost +
1101
- TTI.getCmpSelInstrCost (CmpOpcode, I0->getType (),
1102
- CmpInst::makeCmpResultType (I0->getType ()), Pred) *
1103
- 2 +
1104
+ Ext0Cost + Ext1Cost + CmpCost * 2 +
1104
1105
TTI.getArithmeticInstrCost (I.getOpcode (), I.getType (), CostKind);
1105
1106
1106
1107
// The proposed vector pattern is:
@@ -1110,7 +1111,8 @@ bool VectorCombine::foldExtractedCmps(Instruction &I) {
1110
1111
int ExpensiveIndex = ConvertToShuf == Ext0 ? Index0 : Index1;
1111
1112
auto *CmpTy = cast<FixedVectorType>(CmpInst::makeCmpResultType (X->getType ()));
1112
1113
InstructionCost NewCost = TTI.getCmpSelInstrCost (
1113
- CmpOpcode, X->getType (), CmpInst::makeCmpResultType (X->getType ()), Pred);
1114
+ CmpOpcode, X->getType (), CmpInst::makeCmpResultType (X->getType ()), Pred,
1115
+ CostKind);
1114
1116
SmallVector<int , 32 > ShufMask (VecTy->getNumElements (), PoisonMaskElem);
1115
1117
ShufMask[CheapIndex] = ExpensiveIndex;
1116
1118
NewCost += TTI.getShuffleCost (TargetTransformInfo::SK_PermuteSingleSrc, CmpTy,
0 commit comments