[llvm] b7d2c17 - [LSR] Filter out zero factors. PR50765
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 22 21:14:04 PDT 2021
Author: Max Kazantsev
Date: 2021-06-23T10:43:06+07:00
New Revision: b7d2c173ebbbd48342d498ebc8a1127dbc6d87b1
URL: https://github.com/llvm/llvm-project/commit/b7d2c173ebbbd48342d498ebc8a1127dbc6d87b1
DIFF: https://github.com/llvm/llvm-project/commit/b7d2c173ebbbd48342d498ebc8a1127dbc6d87b1.diff
LOG: [LSR] Filter out zero factors. PR50765
Zero factor leads to division by zero and failure of corresponding
assert as shown in PR50765. We should filter out such factors.
Differential Revision: https://reviews.llvm.org/D104702
Reviewed By: huihuiz, reames
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/test/Transforms/LoopStrengthReduce/pr50765.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index a4cbcd4cffef..5d2d9678ce35 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -2712,13 +2712,13 @@ void LSRInstance::CollectInterestingTypesAndFactors() {
if (const SCEVConstant *Factor =
dyn_cast_or_null<SCEVConstant>(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<SCEVConstant>(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
index 0f2968388b34..8ebb0ca4f229 100644
--- 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.
More information about the llvm-commits
mailing list