[SDAG] Fix incorrect use of undef for boolean contents (PR63055)
authorNikita Popov <npopov@redhat.com>
Thu, 1 Jun 2023 12:18:19 +0000 (14:18 +0200)
committerNikita Popov <npopov@redhat.com>
Thu, 1 Jun 2023 13:19:22 +0000 (15:19 +0200)
commite506bfa7aedb4611db861b89d45d6ece53c42aae
tree44149def6cf4846e2e61226d3b5ec828bc26b7b8
parent3ddd18640af186bd46cb36064cf3bbe00b4b5a52
[SDAG] Fix incorrect use of undef for boolean contents (PR63055)

FoldSetCC() returns UNDEF in a number of cases. However, the SetCC
result must follow BooleanContents. Unless the type is a
pre-legalization i1 or we have UndefinedBooleanContents, the use of
UNDEF will not uphold the requirement that the top bits are either
zero or match the low bit. In such cases, return zero instead.

Fixes https://github.com/llvm/llvm-project/issues/63055.

Differential Revision: https://reviews.llvm.org/D151883
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/test/CodeGen/X86/avx512-insert-extract.ll
llvm/test/CodeGen/X86/setcc.ll