[InstCombine] Support non-splat vectors in icmp eq + add/sub fold
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 29 Jan 2020 17:58:48 +0000 (18:58 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 29 Jan 2020 19:56:58 +0000 (20:56 +0100)
commite086e23024e4fb202628e988f691c158eebf095c
tree7e7697f44258c82876e0d4cd9b68f436eb5cdce6
parent5171587a5f50aecb43e6241c3dbc36f2cf615749
[InstCombine] Support non-splat vectors in icmp eq + add/sub fold

For the

    icmp eq (add X, C1), C2 => icmp eq X, C2-C1
    icmp eq (sub C1, X), C2 => icmp eq X, C1-C2

folds, this allows C1 to be non-splat and contain undefs.
C2 is still splat, due to the structure of the code.

This is to address the remaining part of the regression in D73411,
where demanded element analysis replaces some elements with undef.

Differential Revision: https://reviews.llvm.org/D73647
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-add.ll
llvm/test/Transforms/InstCombine/icmp-sub.ll