OSDN Git Service

[InstCombine] visitMaskedMerge(): when unfolding, sanitize undef constants (PR45955)
authorRoman Lebedev <lebedev.ri@gmail.com>
Sun, 17 May 2020 18:58:55 +0000 (21:58 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sun, 17 May 2020 19:53:03 +0000 (22:53 +0300)
commitfde8eb00e1466cecd0fc6697f8c2ab837c5b7cf3
treed031f06c3ab59ab83ebd12cfec918ee2e578bf08
parenta055e3856f813f73d82e992cfe78dcdb918a39c5
[InstCombine] visitMaskedMerge(): when unfolding, sanitize undef constants (PR45955)

We can't leave undef vector element constants as-is,
it is a miscompile, so we need to sanitize them.

We have two vectors (C and ~C):
* We can't replace undef with 0 in both of them
* We can't replace undef with 0 in only one of them
* We could replace undef with -1 in both of them
* We could replace undef with -1 in only one(!) of them
* We could replace undef with -1 in one and 0 in another one of them.

Therefore, it seems best to go with the last option, since otherwise
we'd loose knowledge that C and ~C have no common bits set,
which seems more important than preserving partial undef knowledge.

Fixes https://bugs.llvm.org/show_bug.cgi?id=45955
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/unfold-masked-merge-with-const-mask-vector.ll