[Polly][NFC] Convert ScopBuilder::getPwAff() to isl++ (#190458)

This commit is contained in:
Michael Kruse 2026-04-04 15:20:15 +02:00 committed by GitHub
parent 5e0efc0f1d
commit fb3fada084
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 14 deletions

View File

@ -260,9 +260,10 @@ class ScopBuilder final {
///
/// Note that this function will also adjust the invalid context
/// accordingly.
__isl_give isl_pw_aff *
getPwAff(BasicBlock *BB, DenseMap<BasicBlock *, isl::set> &InvalidDomainMap,
const SCEV *E, bool NonNegative = false, bool IsInsideDomain = true);
isl::pw_aff getPwAff(BasicBlock *BB,
DenseMap<BasicBlock *, isl::set> &InvalidDomainMap,
const SCEV *E, bool NonNegative = false,
bool IsInsideDomain = true);
/// Create equivalence classes for required invariant accesses.
///

View File

@ -333,14 +333,14 @@ isl::set ScopBuilder::adjustDomainDimensions(isl::set Dom, Loop *OldL,
return Dom;
}
__isl_give isl_pw_aff *
isl::pw_aff
ScopBuilder::getPwAff(BasicBlock *BB,
DenseMap<BasicBlock *, isl::set> &InvalidDomainMap,
const SCEV *E, bool NonNegative, bool IsInsideDomain) {
PWACtx PWAC =
scop->getPwAff(E, BB, NonNegative, &RecordedAssumptions, IsInsideDomain);
InvalidDomainMap[BB] = InvalidDomainMap[BB].unite(PWAC.second);
return PWAC.first.release();
return std::move(PWAC.first);
}
/// Build condition sets for unsigned ICmpInst(s).
@ -359,10 +359,12 @@ __isl_give isl_set *ScopBuilder::buildUnsignedConditionSets(
// Do not take NonNeg assumption on TestVal
// as it might have MSB (Sign bit) set.
isl_pw_aff *TestVal = getPwAff(BB, InvalidDomainMap, SCEV_TestVal,
/*NonNegative=*/false, IsInsideDomain);
/*NonNegative=*/false, IsInsideDomain)
.release();
// Take NonNeg assumption on UpperBound.
isl_pw_aff *UpperBound = getPwAff(BB, InvalidDomainMap, SCEV_UpperBound,
/*NonNegative=*/true, IsInsideDomain);
/*NonNegative=*/true, IsInsideDomain)
.release();
// 0 <= TestVal
isl_set *First =
@ -390,7 +392,8 @@ bool ScopBuilder::buildConditionSets(
isl_pw_aff *LHS, *RHS;
LHS = getPwAff(BB, InvalidDomainMap, SE.getSCEVAtScope(Condition, L),
/*NonNegative=*/false, IsInsideDomain);
/*NonNegative=*/false, IsInsideDomain)
.release();
unsigned NumSuccessors = SI->getNumSuccessors();
ConditionSets.resize(NumSuccessors);
@ -399,7 +402,8 @@ bool ScopBuilder::buildConditionSets(
ConstantInt *CaseValue = Case.getCaseValue();
RHS = getPwAff(BB, InvalidDomainMap, SE.getSCEV(CaseValue),
/*NonNegative=*/false, IsInsideDomain);
/*NonNegative=*/false, IsInsideDomain)
.release();
isl_set *CaseConditionSet =
buildConditionSet(ICmpInst::ICMP_EQ, isl::manage_copy(LHS),
isl::manage(RHS))
@ -432,9 +436,11 @@ bool ScopBuilder::buildConditionSets(
const SCEV *RHSSCEV = SE.getZero(LHSSCEV->getType());
bool NonNeg = false;
isl_pw_aff *LHS =
getPwAff(BB, InvalidDomainMap, LHSSCEV, NonNeg, IsInsideDomain);
getPwAff(BB, InvalidDomainMap, LHSSCEV, NonNeg, IsInsideDomain)
.release();
isl_pw_aff *RHS =
getPwAff(BB, InvalidDomainMap, RHSSCEV, NonNeg, IsInsideDomain);
getPwAff(BB, InvalidDomainMap, RHSSCEV, NonNeg, IsInsideDomain)
.release();
ConsequenceCondSet = buildConditionSet(ICmpInst::ICMP_SLE, isl::manage(LHS),
isl::manage(RHS))
.release();
@ -518,9 +524,10 @@ bool ScopBuilder::buildConditionSets(
/*IsStrictUpperBound=*/false, IsInsideDomain);
break;
default:
LHS = getPwAff(BB, InvalidDomainMap, LeftOperand, NonNeg, IsInsideDomain);
RHS =
getPwAff(BB, InvalidDomainMap, RightOperand, NonNeg, IsInsideDomain);
LHS = getPwAff(BB, InvalidDomainMap, LeftOperand, NonNeg, IsInsideDomain)
.release();
RHS = getPwAff(BB, InvalidDomainMap, RightOperand, NonNeg, IsInsideDomain)
.release();
ConsequenceCondSet = buildConditionSet(ICond->getPredicate(),
isl::manage(LHS), isl::manage(RHS))
.release();