Index: llvm/lib/Analysis/ValueTracking.cpp =================================================================== --- llvm/lib/Analysis/ValueTracking.cpp +++ llvm/lib/Analysis/ValueTracking.cpp @@ -2463,6 +2463,13 @@ match(Induction, m_NUWAdd(m_Specific(PN), m_ConstantInt(X)))) && !X->isNegative()) return true; + else if (!C->isOne() && Q.IIQ.UseInstrInfo && + (match(Induction, + m_NSWMul(m_Specific(PN), m_ConstantInt(X))) || + match(Induction, + m_NUWMul(m_Specific(PN), m_ConstantInt(X)))) && + !X->isNegative() && !X->isZero() && !X->isOne()) + return true; } } } Index: llvm/test/Analysis/ValueTracking/monotonic-phi.ll =================================================================== --- llvm/test/Analysis/ValueTracking/monotonic-phi.ll +++ llvm/test/Analysis/ValueTracking/monotonic-phi.ll @@ -47,3 +47,19 @@ ; CHECK: ret i1 false ret i1 %cmp } + +; CHECK-LABEL: @test4 +define i1 @test4(i8 %p, i8* %pq, i8 %n, i8 %r) { +entry: + br label %loop +loop: + %A = phi i8 [ 2, %entry ], [ %next, %loop ] + %next = mul nsw i8 %A, 2 + %cmp1 = icmp eq i8 %A, %n + br i1 %cmp1, label %exit, label %loop +exit: + %add = or i8 %A, %r + %cmp = icmp eq i8 %add, 0 + ; CHECK: ret i1 false + ret i1 %cmp +}