[LSR] Check for signed overflow in NarrowSearchSpaceByDetectingSupersets.
authorFlorian Hahn <flo@fhahn.com>
Fri, 15 Mar 2019 12:17:36 +0000 (12:17 +0000)
committerFlorian Hahn <flo@fhahn.com>
Fri, 15 Mar 2019 12:17:36 +0000 (12:17 +0000)
commitd9e88f7b7fef8f1a3dd48cf245365b65cc330eb5
tree429c533d7d2cb5fd6e15e2c8fdb88645b83b4ef0
parent04188fc0c6e61b62f2c8efde620d637bd7caf926
[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
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/test/Transforms/LoopStrengthReduce/X86/lsr-overflow.ll [new file with mode: 0644]