diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -2712,13 +2712,13 @@ if (const SCEVConstant *Factor = dyn_cast_or_null(getExactSDiv(NewStride, OldStride, SE, true))) { - if (Factor->getAPInt().getMinSignedBits() <= 64) + if (Factor->getAPInt().getMinSignedBits() <= 64 && !Factor->isZero()) Factors.insert(Factor->getAPInt().getSExtValue()); } else if (const SCEVConstant *Factor = dyn_cast_or_null(getExactSDiv(OldStride, NewStride, SE, true))) { - if (Factor->getAPInt().getMinSignedBits() <= 64) + if (Factor->getAPInt().getMinSignedBits() <= 64 && !Factor->isZero()) Factors.insert(Factor->getAPInt().getSExtValue()); } } diff --git a/llvm/test/Transforms/LoopStrengthReduce/pr50765.ll b/llvm/test/Transforms/LoopStrengthReduce/pr50765.ll --- a/llvm/test/Transforms/LoopStrengthReduce/pr50765.ll +++ b/llvm/test/Transforms/LoopStrengthReduce/pr50765.ll @@ -1,6 +1,4 @@ ; RUN: opt -S -loop-reduce < %s | FileCheck %s -; XFAIL: * -; REQUIRES: asserts ; ;This test produces zero factor that becomes a denumerator and fails an assetion.