diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-04-14 19:37:47 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-04-14 19:39:59 +0200 |
commit | 0d91075f772d3f0e2cf6449b534a726d4d944c62 (patch) | |
tree | cf7e417d0e380a37c180fe90fe32bae9b026854f /llvm/lib/Analysis/ValueTracking.cpp | |
parent | b15c54ad687a1d906ee22acba0104c2f3f0dd2f9 (diff) | |
download | llvm-0d91075f772d3f0e2cf6449b534a726d4d944c62.zip llvm-0d91075f772d3f0e2cf6449b534a726d4d944c62.tar.gz llvm-0d91075f772d3f0e2cf6449b534a726d4d944c62.tar.bz2 |
[ValueTracking] Don't require strictly positive for mul nsw recurrence
Just like in the mul nuw case, it's sufficient that the step is
non-zero. If the step is negative, then the values will jump
between positive and negative, "crossing" zero, but the value of
the recurrence is never actually zero.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index c1e7cf7..d8963c6 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -2231,9 +2231,8 @@ static bool isNonZeroRecurrence(const PHINode *PN) { (BO->hasNoSignedWrap() && match(Step, m_APInt(StepC)) && StartC->isNegative() == StepC->isNegative()); case Instruction::Mul: - return match(Step, m_APInt(StepC)) && - ((BO->hasNoUnsignedWrap() && !StepC->isNullValue()) || - (BO->hasNoSignedWrap() && StepC->isStrictlyPositive())); + return (BO->hasNoUnsignedWrap() || BO->hasNoSignedWrap()) && + match(Step, m_APInt(StepC)) && !StepC->isNullValue(); case Instruction::Shl: return BO->hasNoUnsignedWrap() || BO->hasNoSignedWrap(); case Instruction::AShr: |