diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -4011,7 +4011,8 @@ // If the comparison is with the result of a phi instruction, check whether // doing the compare with each incoming phi value yields a common result. if (isa(LHS) || isa(RHS)) - if (Value *V = threadCmpOverPHI(Pred, LHS, RHS, Q, MaxRecurse)) + if (Value *V = threadCmpOverPHI(Pred, LHS, RHS, Q, + MaxRecurse > 1 ? 1 : MaxRecurse)) return V; return nullptr; @@ -4237,7 +4238,8 @@ // If the comparison is with the result of a phi instruction, check whether // doing the compare with each incoming phi value yields a common result. if (isa(LHS) || isa(RHS)) - if (Value *V = threadCmpOverPHI(Pred, LHS, RHS, Q, MaxRecurse)) + if (Value *V = threadCmpOverPHI(Pred, LHS, RHS, Q, + MaxRecurse > 1 ? 1 : MaxRecurse)) return V; return nullptr;