]> granicus.if.org Git - llvm/commit
[InstCombine] prevent possible miscompile with negate+sdiv of vector op
authorSanjay Patel <spatel@rotateright.com>
Tue, 9 Apr 2019 14:09:06 +0000 (14:09 +0000)
committerSanjay Patel <spatel@rotateright.com>
Tue, 9 Apr 2019 14:09:06 +0000 (14:09 +0000)
commit30ccf8222e12c9774984331deea69aa8b8618dc0
tree04da55d2ef7440e46d63a18a10d75b9fdc4f76be
parent396f459f9596bf087a0e919284d82a8f728b2e52
[InstCombine] prevent possible miscompile with negate+sdiv of vector op

// 0 - (X sdiv C)  -> (X sdiv -C)  provided the negation doesn't overflow.

This fold has been around for many years and nobody noticed the potential
vector miscompile from overflow until recently...
So it seems unlikely that there's much demand for a vector sdiv optimization
on arbitrary vector constants, so just limit the matching to splat constants
to avoid the possible bug.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358005 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineAddSub.cpp
test/Transforms/InstCombine/div.ll