Skip to content

Commit 6fadfdc

Browse files
committed
[SCEV] Add SCEVUnionPredicate::getUnionWith method
1 parent 802c010 commit 6fadfdc

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

llvm/include/llvm/Analysis/ScalarEvolution.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,15 @@ class LLVM_ABI SCEVUnionPredicate final : public SCEVPredicate {
427427

428428
ArrayRef<const SCEVPredicate *> getPredicates() const { return Preds; }
429429

430+
/// Returns a new SCEVUnionPredicate that is the union of this predicate
431+
/// and the given predicate \p N.
432+
SCEVUnionPredicate getUnionWith(const SCEVPredicate *N,
433+
ScalarEvolution &SE) const {
434+
SCEVUnionPredicate Result(Preds, SE);
435+
Result.add(N, SE);
436+
return Result;
437+
}
438+
430439
/// Implementation of the SCEVPredicate interface
431440
bool isAlwaysTrue() const override;
432441
bool implies(const SCEVPredicate *N, ScalarEvolution &SE) const override;

llvm/lib/Analysis/DependenceAnalysis.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,10 +1382,7 @@ bool DependenceInfo::strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst,
13821382
if (UnderRuntimeAssumptions) {
13831383
const SCEVPredicate *Pred = SE->getComparePredicate(
13841384
ICmpInst::ICMP_NE, Coeff, SE->getZero(Coeff->getType()));
1385-
SmallVector<const SCEVPredicate *, 4> NewPreds(
1386-
Result.Assumptions.getPredicates());
1387-
NewPreds.push_back(Pred);
1388-
Result.Assumptions = SCEVUnionPredicate(NewPreds, *SE);
1385+
Result.Assumptions = Result.Assumptions.getUnionWith(Pred, *SE);
13891386
LLVM_DEBUG(dbgs() << "\t Added runtime assumption: " << *Coeff
13901387
<< " != 0\n");
13911388
} else {

0 commit comments

Comments
 (0)