forked from OSchip/llvm-project
[ARM][MVE] Tail-predication: use unsigned SCEV ranges for tripcount
Loop tripcount expressions have a positive range, so use unsigned SCEV ranges for them. Differential Revision: https://reviews.llvm.org/D87608
This commit is contained in:
parent
aa8be5aeea
commit
635b87511e
|
@ -457,13 +457,10 @@ bool MVETailPredication::IsSafeActiveMask(IntrinsicInst *ActiveLaneMask,
|
||||||
// upperbound(TC) <= UINT_MAX - VectorWidth
|
// upperbound(TC) <= UINT_MAX - VectorWidth
|
||||||
//
|
//
|
||||||
unsigned SizeInBits = TripCount->getType()->getScalarSizeInBits();
|
unsigned SizeInBits = TripCount->getType()->getScalarSizeInBits();
|
||||||
auto Diff = APInt(SizeInBits, ~0) - APInt(SizeInBits, VectorWidth);
|
auto MaxMinusVW = APInt(SizeInBits, ~0) - APInt(SizeInBits, VectorWidth);
|
||||||
uint64_t MaxMinusVW = Diff.getZExtValue();
|
APInt UpperboundTC = SE->getUnsignedRangeMax(TC);
|
||||||
// FIXME: since ranges can be negative we work with signed ranges here, but
|
|
||||||
// we shouldn't extract the zext'ed values for them.
|
|
||||||
uint64_t UpperboundTC = SE->getSignedRange(TC).getUpper().getZExtValue();
|
|
||||||
|
|
||||||
if (UpperboundTC > MaxMinusVW && !ForceTailPredication) {
|
if (UpperboundTC.ugt(MaxMinusVW) && !ForceTailPredication) {
|
||||||
LLVM_DEBUG(dbgs() << "ARM TP: Overflow possible in tripcount rounding:\n";
|
LLVM_DEBUG(dbgs() << "ARM TP: Overflow possible in tripcount rounding:\n";
|
||||||
dbgs() << "upperbound(TC) <= UINT_MAX - VectorWidth\n";
|
dbgs() << "upperbound(TC) <= UINT_MAX - VectorWidth\n";
|
||||||
dbgs() << UpperboundTC << " <= " << MaxMinusVW << " == false\n";);
|
dbgs() << UpperboundTC << " <= " << MaxMinusVW << " == false\n";);
|
||||||
|
@ -501,8 +498,8 @@ bool MVETailPredication::IsSafeActiveMask(IntrinsicInst *ActiveLaneMask,
|
||||||
auto *Ceil = SE->getUDivExpr(ECPlusVWMinus1,
|
auto *Ceil = SE->getUDivExpr(ECPlusVWMinus1,
|
||||||
SE->getSCEV(ConstantInt::get(TripCount->getType(), VectorWidth)));
|
SE->getSCEV(ConstantInt::get(TripCount->getType(), VectorWidth)));
|
||||||
|
|
||||||
ConstantRange RangeCeil = SE->getSignedRange(Ceil) ;
|
ConstantRange RangeCeil = SE->getUnsignedRange(Ceil) ;
|
||||||
ConstantRange RangeTC = SE->getSignedRange(TC) ;
|
ConstantRange RangeTC = SE->getUnsignedRange(TC) ;
|
||||||
if (!RangeTC.isSingleElement()) {
|
if (!RangeTC.isSingleElement()) {
|
||||||
auto ZeroRange =
|
auto ZeroRange =
|
||||||
ConstantRange(APInt(TripCount->getType()->getScalarSizeInBits(), 0));
|
ConstantRange(APInt(TripCount->getType()->getScalarSizeInBits(), 0));
|
||||||
|
|
Loading…
Reference in New Issue