Skip to content

Commit 0ca3ab6

Browse files
committed
[SLP] Refactor cost function to treat freeze instructions as zero cost
1 parent f568419 commit 0ca3ab6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9865,11 +9865,10 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
98659865
case Instruction::AShr:
98669866
case Instruction::And:
98679867
case Instruction::Or:
9868-
case Instruction::Xor:
9869-
case Instruction::Freeze: {
9868+
case Instruction::Xor: {
98709869
auto GetScalarCost = [&](unsigned Idx) {
98719870
auto *VI = cast<Instruction>(UniqueValues[Idx]);
9872-
unsigned OpIdx = isa<UnaryOperator>(VI) || isa<FreezeInst>(VI) ? 0 : 1;
9871+
unsigned OpIdx = isa<UnaryOperator>(VI) ? 0 : 1;
98739872
TTI::OperandValueInfo Op1Info = TTI::getOperandInfo(VI->getOperand(0));
98749873
TTI::OperandValueInfo Op2Info =
98759874
TTI::getOperandInfo(VI->getOperand(OpIdx));
@@ -9888,7 +9887,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
98889887
return CommonCost;
98899888
}
98909889
}
9891-
unsigned OpIdx = isa<UnaryOperator>(VL0) || isa<FreezeInst>(VL0) ? 0 : 1;
9890+
unsigned OpIdx = isa<UnaryOperator>(VL0) ? 0 : 1;
98929891
TTI::OperandValueInfo Op1Info = getOperandInfo(E->getOperand(0));
98939892
TTI::OperandValueInfo Op2Info = getOperandInfo(E->getOperand(OpIdx));
98949893
return TTI->getArithmeticInstrCost(ShuffleOrOp, VecTy, CostKind, Op1Info,
@@ -10121,6 +10120,9 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
1012110120
};
1012210121
return GetCostDiff(GetScalarCost, GetVectorCost);
1012310122
}
10123+
case Instruction::Freeze: {
10124+
return CommonCost;
10125+
}
1012410126
default:
1012510127
llvm_unreachable("Unknown instruction");
1012610128
}

0 commit comments

Comments
 (0)