[InstCombine] Fix potentially buggy code in `((%x & C) == 0) --> %x u< (-C)` transform
authorNoah Goldstein <goldstein.w.n@gmail.com>
Mon, 9 Jan 2023 10:38:36 +0000 (11:38 +0100)
committerNikita Popov <npopov@redhat.com>
Mon, 9 Jan 2023 10:44:11 +0000 (11:44 +0100)
commite6375ca6dc5ba263ad3d9b6d779c5cf5b0f2e9ba
tree7b414aced86f2efbd6e716164b5c5844a0e644af
parent05d722a11d779bd1d7990790b390f0d44a3d8afe
[InstCombine] Fix potentially buggy code in `((%x & C) == 0) --> %x u< (-C)` transform

While demanded bits constant shrinking appears to prevent this in
practice right now, it is principally possible for C2 to have
set bits that are known not-needed (zeroable). See: D140858

`+` will overflow here, `|` will get the right logic.

Differential Revision: https://reviews.llvm.org/D141089
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp