OSDN Git Service

[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)
commitf75dbeb8e7dfbf8a512fa08f4c25509dae63b310
treecd0189f3880b7067986b013d9b35df24ee6fb720
parent1154d31e8c429e53307d3fc0edd13d9b261c26dc
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356256 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/LoopStrengthReduce.cpp
test/Transforms/LoopStrengthReduce/X86/lsr-overflow.ll [new file with mode: 0644]