diff options
author | Florian Hahn <flo@fhahn.com> | 2019-03-15 12:17:36 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2019-03-15 12:17:36 +0000 |
commit | d9e88f7b7fef8f1a3dd48cf245365b65cc330eb5 (patch) | |
tree | 429c533d7d2cb5fd6e15e2c8fdb88645b83b4ef0 /llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | |
parent | 04188fc0c6e61b62f2c8efde620d637bd7caf926 (diff) | |
download | bcm5719-llvm-d9e88f7b7fef8f1a3dd48cf245365b65cc330eb5.tar.gz bcm5719-llvm-d9e88f7b7fef8f1a3dd48cf245365b65cc330eb5.zip |
[LSR] Check for signed overflow in NarrowSearchSpaceByDetectingSupersets.
We are adding a sign extended IR value to an int64_t, which can cause
signed overflows, as in the attached test case, where we have a formula
with BaseOffset = -1 and a constant with numeric_limits<int64_t>::min().
If the addition would overflow, skip the simplification for this
formula. Note that the target triple is required to trigger the failure.
Reviewers: qcolombet, gilr, kparzysz, efriedma
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D59211
llvm-svn: 356256
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index e4b9c44ea84..340f5db4bdb 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -4423,7 +4423,9 @@ void LSRInstance::NarrowSearchSpaceByDetectingSupersets() { I = F.BaseRegs.begin(), E = F.BaseRegs.end(); I != E; ++I) { if (const SCEVConstant *C = dyn_cast<SCEVConstant>(*I)) { Formula NewF = F; - NewF.BaseOffset += C->getValue()->getSExtValue(); + //FIXME: Formulas should store bitwidth to do wrapping properly. + // See PR41034. + NewF.BaseOffset += (uint64_t)C->getValue()->getSExtValue(); NewF.BaseRegs.erase(NewF.BaseRegs.begin() + (I - F.BaseRegs.begin())); if (LU.HasFormulaWithSameRegs(NewF)) { |