Files
clang-p2996/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Noah Goldstein 6cdc229a64 [InstCombine] Fix bug in FoldOpIntoSelect where we would incorrectly fold undef as constant
D146349 Introduced the ability to use the information from the
`select` condition to deduce constants as we folded a binop into
select. I.e if the `select` cond was `icmp eq %A, 10`, then in the
true-arm of `select`, we would be able to replace usage of `A` with
`10`.

This is broken for vectors that contain `undef` elements. I.e with
`icmp eq %A, <10, undef>`, subsituting `<10, undef>` for `A` can
result in creating a more undefined result than we otherwise would
have.

We fix the issue with simply checking if the candidate constant for
substituting may contain `undef` elements and don't do it in that
case.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D149592
2023-05-01 17:23:54 -05:00

168 KiB