HomePhabricator

[InstCombine] visitMaskedMerge(): when unfolding, sanitize undef constants…

Authored by lebedev.ri on Sun, May 17, 11:58 AM.

Description

[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

Details