1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

[LV] Use ScalarEvolution::getURemExpr to reduce duplication.

ScalarEvolution should be able to handle both constant and variable trip
counts using getURemExpr, so we do not have to handle them separately.

This is a small simplification of a56280094e08.

Reviewed By: gilr

Differential Revision: https://reviews.llvm.org/D93677
This commit is contained in:
Florian Hahn 2020-12-22 14:44:09 +00:00
parent e6292b9b96
commit 4cdccd0b93

View File

@ -5506,20 +5506,15 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
"MaxVF must be a power of 2");
unsigned MaxVFtimesIC =
UserIC ? MaxVF.getFixedValue() * UserIC : MaxVF.getFixedValue();
if (TC > 0 && TC % MaxVFtimesIC == 0) {
// Accept MaxVF if we do not have a tail.
LLVM_DEBUG(dbgs() << "LV: No tail will remain for any chosen VF.\n");
return MaxVF;
}
// Avoid tail folding if the trip count is known to be a multiple of any VF we
// chose.
ScalarEvolution *SE = PSE.getSE();
const SCEV *BackedgeTakenCount = PSE.getBackedgeTakenCount();
const SCEV *ExitCount = SE->getAddExpr(
BackedgeTakenCount, SE->getOne(BackedgeTakenCount->getType()));
unsigned TCisMultipleOf = 1 << SE->GetMinTrailingZeros(ExitCount);
if (TCisMultipleOf % MaxVFtimesIC == 0) {
const SCEV *Rem = SE->getURemExpr(
ExitCount, SE->getConstant(BackedgeTakenCount->getType(), MaxVFtimesIC));
if (Rem->isZero()) {
// Accept MaxVF if we do not have a tail.
LLVM_DEBUG(dbgs() << "LV: No tail will remain for any chosen VF.\n");
return MaxVF;