[InstCombine] replace undef elements in vector constant when doing icmp folds (PR44383)
authorSanjay Patel <spatel@rotateright.com>
Fri, 3 Jan 2020 14:15:58 +0000 (09:15 -0500)
committerSanjay Patel <spatel@rotateright.com>
Fri, 3 Jan 2020 14:16:57 +0000 (09:16 -0500)
commit164058274364670c8b59055b4689ae7e1720268e
tree514e82bf5fadb3150d643e7cd3a4e548767afc15
parent8382f8714539cf2aba0c194d789e7c2909608be2
[InstCombine] replace undef elements in vector constant when doing icmp folds (PR44383)

As shown in P44383:
https://bugs.llvm.org/show_bug.cgi?id=44383
...we can't safely propagate a vector constant through this icmp fold
if that vector constant contains undefined elements.

We know that each defined element of the constant is safe though, so
find the first of those and replicate it into the formerly undef lanes.

Differential Revision: https://reviews.llvm.org/D72101
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll
llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sgt-to-icmp-sgt.ll
llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-slt-to-icmp-sgt.ll
llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ugt-to-icmp-ugt.ll
llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ult-to-icmp-ugt.ll