Skip to content

Commit

Permalink
Update MustExitScalarEvolution.cpp for upstream LLVM changes
Browse files Browse the repository at this point in the history
Fixes issue #2097
  • Loading branch information
dklimkin authored Oct 2, 2024
1 parent 7425c37 commit 2d68c92
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion 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,7 +230,10 @@ 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
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 2d68c92

Please sign in to comment.