[PATCH] D23723: [SLP] Avoid signed integer overflow

Matthew Simpson via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 19 12:02:03 PDT 2016


mssimpso created this revision.
mssimpso added a reviewer: mkuper.
mssimpso added subscribers: hans, llvm-commits, kcc.
Herald added subscribers: mzolotukhin, mcrosier.

The test case included with r279125 exposed an existing signed integer overflow. Since getTreeCost can return INT_MAX, we have to be careful to avoid undefined behavior when summing it with other costs, such as getReductionCost.

This patch adds a signed version of SaturatingAdd, and uses it in SLPVectorizer to avoid overflow. It also modifies the test case for r279125, since it was dependent on an incorrect cost calculation. We now just check to ensure we do not crash.

https://reviews.llvm.org/D23723

Files:
  include/llvm/Support/MathExtras.h
  lib/Transforms/Vectorize/SLPVectorizer.cpp
  test/Transforms/SLPVectorizer/AArch64/gather-root.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23723.68718.patch
Type: text/x-patch
Size: 8622 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160819/43eaeaa2/attachment.bin>


More information about the llvm-commits mailing list