OSDN Git Service

[SLP] Avoid signed integer overflow
authorMatthew Simpson <mssimpso@codeaurora.org>
Tue, 23 Aug 2016 20:48:50 +0000 (20:48 +0000)
committerMatthew Simpson <mssimpso@codeaurora.org>
Tue, 23 Aug 2016 20:48:50 +0000 (20:48 +0000)
commit35b891658214a020e47b3e92f6a51f0270859ebb
tree86aeb0e352da46ad96259b1f23ca7fc376176ca6
parent9e9267d31d0ed3088ee4384af17a44639a105777
[SLP] Avoid signed integer overflow

The test case included with r279125 exposed an existing signed integer
overflow. Since getTreeCost can return INT_MAX, we can't sum this cost together
with other costs, such as getReductionCost.

This patch removes the possibility of assigning a cost of INT_MAX. Since we
were previously using INT_MAX as an indicator for "should not vectorize", we
now explicitly check this condition with "isTreeTinyAndNotFullyVectorizable"
before computing a cost.

This patch adds a run-line to the test case used for r279125 that ensures we
don't vectorize. Previously, this line would vectorize the test case by chance
due to undefined behavior in the cost calculation.

Differential Revision: https://reviews.llvm.org/D23723

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279562 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Vectorize/SLPVectorizer.cpp
test/Transforms/SLPVectorizer/AArch64/gather-root.ll