@@ -7571,7 +7571,7 @@ static bool programUndefinedIfUndefOrPoison(const Value *V, bool PoisonOnly);
7571
7571
7572
7572
Use *llvm::canFoldFreezeIntoRecurrence (
7573
7573
PHINode *PN, DominatorTree *DT, bool &StartNeedsFreeze,
7574
- SmallVectorImpl<Instruction *> *DropFlags) {
7574
+ SmallVectorImpl<Instruction *> *DropFlags, unsigned Depth ) {
7575
7575
// Detect whether this is a recurrence with a start value and some number of
7576
7576
// backedge values. We'll check whether we can push the freeze through the
7577
7577
// backedge values (possibly dropping poison flags along the way) until we
@@ -7597,7 +7597,8 @@ Use *llvm::canFoldFreezeIntoRecurrence(
7597
7597
7598
7598
Value *StartV = StartU->get ();
7599
7599
BasicBlock *StartBB = PN->getIncomingBlock (*StartU);
7600
- StartNeedsFreeze = !isGuaranteedNotToBeUndefOrPoison (StartV);
7600
+ StartNeedsFreeze = !isGuaranteedNotToBeUndefOrPoison (
7601
+ StartV, /* AC=*/ nullptr , /* CtxI=*/ nullptr , /* DT=*/ nullptr , Depth);
7601
7602
// We can't insert freeze if the start value is the result of the
7602
7603
// terminator (e.g. an invoke).
7603
7604
if (StartNeedsFreeze && StartBB->getTerminator () == StartV)
@@ -7609,11 +7610,13 @@ Use *llvm::canFoldFreezeIntoRecurrence(
7609
7610
if (!Visited.insert (V).second )
7610
7611
continue ;
7611
7612
7612
- if (Visited.size () > 32 )
7613
+ if (Visited.size () > MaxRecurrenceSearchDepth )
7613
7614
return nullptr ; // Limit the total number of values we inspect.
7614
7615
7615
7616
// Assume that PN is non-poison, because it will be after the transform.
7616
- if (V == PN || isGuaranteedNotToBeUndefOrPoison (V))
7617
+ if (V == PN ||
7618
+ isGuaranteedNotToBeUndefOrPoison (V, /* AC=*/ nullptr , /* CtxI=*/ nullptr ,
7619
+ /* DT=*/ nullptr , Depth))
7617
7620
continue ;
7618
7621
7619
7622
Instruction *I = dyn_cast<Instruction>(V);
@@ -7719,9 +7722,9 @@ static bool isGuaranteedNotToBeUndefOrPoison(
7719
7722
return true ;
7720
7723
7721
7724
bool StartNeedsFreeze;
7722
- if (canFoldFreezeIntoRecurrence (const_cast <PHINode *>(PN),
7723
- const_cast <DominatorTree *>(DT),
7724
- StartNeedsFreeze ) &&
7725
+ if (canFoldFreezeIntoRecurrence (
7726
+ const_cast <PHINode *>(PN), const_cast <DominatorTree *>(DT),
7727
+ StartNeedsFreeze, /* DropFlags= */ nullptr , Depth ) &&
7725
7728
!StartNeedsFreeze)
7726
7729
return true ;
7727
7730
} else if (!::canCreateUndefOrPoison (Opr, Kind,
0 commit comments