Skip to content

Commit

Permalink
Update MustExitScalarEvolution.cpp for upstream LLVM changes (#2098)
Browse files Browse the repository at this point in the history
* Update MustExitScalarEvolution.cpp for upstream LLVM changes

Fixes issue #2097

* Fix formatting as prescribed.
  • Loading branch information
dklimkin authored Oct 2, 2024
1 parent b208929 commit 20d8738
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions enzyme/Enzyme/MustExitScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "MustExitScalarEvolution.h"
#include "FunctionUtils.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/ScalarEvolution.h"

Expand Down Expand Up @@ -229,12 +230,15 @@ MustExitScalarEvolution::computeExitLimitFromCondImpl(
!isa<SCEVCouldNotCompute>(BECount))
MaxBECount = getConstant(getUnsignedRangeMax(BECount));

#if LLVM_VERSION_MAJOR >= 16
#if LLVM_VERSION_MAJOR >= 20
return ExitLimit(BECount, MaxBECount, MaxBECount, false,
{ArrayRef(EL0.Predicates), ArrayRef(EL1.Predicates)});
#elif LLVM_VERSION_MAJOR >= 16
return ExitLimit(BECount, MaxBECount, MaxBECount, false,
{&EL0.Predicates, &EL1.Predicates});
#else
return ExitLimit(BECount, MaxBECount, false,
{&EL0.Predicates, &EL1.Predicates});
return ExitLimit(BECount, MaxBECount, false,
{&EL0.Predicates, &EL1.Predicates});
#endif
}
if (BO->getOpcode() == Instruction::Or) {
Expand Down Expand Up @@ -273,8 +277,13 @@ MustExitScalarEvolution::computeExitLimitFromCondImpl(
if (EL0.ExactNotTaken == EL1.ExactNotTaken)
BECount = EL0.ExactNotTaken;
}
#if LLVM_VERSION_MAJOR >= 20
return ExitLimit(BECount, MaxBECount, MaxBECount, false,
{ArrayRef(EL0.Predicates), ArrayRef(EL1.Predicates)});
#else
return ExitLimit(BECount, MaxBECount, MaxBECount, false,
{&EL0.Predicates, &EL1.Predicates});
#endif
#else
if (EL0.MaxNotTaken == getCouldNotCompute())
MaxBECount = EL1.MaxNotTaken;
Expand Down Expand Up @@ -741,7 +750,11 @@ static SCEV::NoWrapFlags StrengthenNoWrapFlags(ScalarEvolution *SE,
ScalarEvolution::ExitLimit MustExitScalarEvolution::howManyLessThans(
const SCEV *LHS, const SCEV *RHS, const Loop *L, bool IsSigned,
bool ControlsExit, bool AllowPredicates) {
#if LLVM_VERSION_MAJOR >= 20
SmallVector<const SCEVPredicate *, 4> Predicates;
#else
SmallPtrSet<const SCEVPredicate *, 4> Predicates;
#endif

const SCEVAddRecExpr *IV = dyn_cast<SCEVAddRecExpr>(LHS);
bool PredicatedIV = false;
Expand Down

0 comments on commit 20d8738

Please sign in to comment.