[InstCombine] Fold a mul with bool value into and
authorzhongyunde <zhongyunde@huawei.com>
Mon, 30 May 2022 13:04:40 +0000 (21:04 +0800)
committerzhongyunde <zhongyunde@huawei.com>
Mon, 30 May 2022 13:05:00 +0000 (21:05 +0800)
commit3e6ba89055c80e6360b7605464520711b30084a6
treef401e27eee50a4c193c12a9c5b28a239311c5622
parent18c1ee04de448a6a4babbaf8e5ba42866339b466
[InstCombine] Fold a mul with bool value into and

Fixes https://github.com/llvm/llvm-project/issues/55599
  X * Y --> X & Y, iff X, Y can be only {0, 1}.
https://alive2.llvm.org/ce/z/_RsTKF

Reviewed By: spatel, nikic

Differential Revision: https://reviews.llvm.org/D126040
llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/test/Transforms/InstCombine/mul-masked-bits.ll