@@ -428,9 +428,9 @@ bool VectorCombine::isExtractExtractCheap(ExtractElementInst *Ext0,
428428 " Expected a compare" );
429429 CmpInst::Predicate Pred = cast<CmpInst>(I).getPredicate ();
430430 ScalarOpCost = TTI.getCmpSelInstrCost (
431- Opcode, ScalarTy, CmpInst::makeCmpResultType (ScalarTy), Pred);
431+ Opcode, ScalarTy, CmpInst::makeCmpResultType (ScalarTy), Pred, CostKind );
432432 VectorOpCost = TTI.getCmpSelInstrCost (
433- Opcode, VecTy, CmpInst::makeCmpResultType (VecTy), Pred);
433+ Opcode, VecTy, CmpInst::makeCmpResultType (VecTy), Pred, CostKind );
434434 }
435435
436436 // Get cost estimates for the extract elements. These costs will factor into
@@ -991,9 +991,9 @@ bool VectorCombine::scalarizeBinopOrCmp(Instruction &I) {
991991 if (IsCmp) {
992992 CmpInst::Predicate Pred = cast<CmpInst>(I).getPredicate ();
993993 ScalarOpCost = TTI.getCmpSelInstrCost (
994- Opcode, ScalarTy, CmpInst::makeCmpResultType (ScalarTy), Pred);
994+ Opcode, ScalarTy, CmpInst::makeCmpResultType (ScalarTy), Pred, CostKind );
995995 VectorOpCost = TTI.getCmpSelInstrCost (
996- Opcode, VecTy, CmpInst::makeCmpResultType (VecTy), Pred);
996+ Opcode, VecTy, CmpInst::makeCmpResultType (VecTy), Pred, CostKind );
997997 } else {
998998 ScalarOpCost = TTI.getArithmeticInstrCost (Opcode, ScalarTy, CostKind);
999999 VectorOpCost = TTI.getArithmeticInstrCost (Opcode, VecTy, CostKind);
@@ -1093,14 +1093,15 @@ bool VectorCombine::foldExtractedCmps(Instruction &I) {
10931093 return false ;
10941094
10951095 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+
10991103 InstructionCost OldCost =
1100- Ext0Cost + Ext1Cost +
1101- TTI.getCmpSelInstrCost (CmpOpcode, I0->getType (),
1102- CmpInst::makeCmpResultType (I0->getType ()), Pred) *
1103- 2 +
1104+ Ext0Cost + Ext1Cost + CmpCost * 2 +
11041105 TTI.getArithmeticInstrCost (I.getOpcode (), I.getType (), CostKind);
11051106
11061107 // The proposed vector pattern is:
@@ -1110,7 +1111,8 @@ bool VectorCombine::foldExtractedCmps(Instruction &I) {
11101111 int ExpensiveIndex = ConvertToShuf == Ext0 ? Index0 : Index1;
11111112 auto *CmpTy = cast<FixedVectorType>(CmpInst::makeCmpResultType (X->getType ()));
11121113 InstructionCost NewCost = TTI.getCmpSelInstrCost (
1113- CmpOpcode, X->getType (), CmpInst::makeCmpResultType (X->getType ()), Pred);
1114+ CmpOpcode, X->getType (), CmpInst::makeCmpResultType (X->getType ()), Pred,
1115+ CostKind);
11141116 SmallVector<int , 32 > ShufMask (VecTy->getNumElements (), PoisonMaskElem);
11151117 ShufMask[CheapIndex] = ExpensiveIndex;
11161118 NewCost += TTI.getShuffleCost (TargetTransformInfo::SK_PermuteSingleSrc, CmpTy,
0 commit comments