[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)
commitf62dcea7ed69df95b037712b1860bb99c553c808
tree594186b06c3428a0e9c117ecdbba11e3e6fde357
parentaf5834596bf885a1e4f71b79c222ffdb8a640656
[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

llvm-svn: 358005
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/test/Transforms/InstCombine/div.ll