[InstSimplify] with logical ops: (X | Y) ? 0 : X --> 0
authorZhongyunde <zhongyunde@huawei.com>
Tue, 25 Apr 2023 13:47:41 +0000 (21:47 +0800)
committerZhongyunde <zhongyunde@huawei.com>
Tue, 25 Apr 2023 13:51:41 +0000 (21:51 +0800)
commitb80f31c48d63743ece1062f30d5f747a03ee5695
tree2015bfdf4fa6398e6f2c23da57e58f4d25a84d4b
parent9d92f479c3fb708ea0cad8aa6fa70fd46f753123
[InstSimplify] with logical ops: (X | Y) ? 0 : X --> 0

Use simplifySelectWithICmpEq to handle the implied equalities from the icmp-or,
then both of ICMP_NE and ICMP_EQ will be addressed
  (X | Y) == 0 ?  X : 0 --> 0 (commuted 2 ways)
  (X | Y) != 0 ?  0 : X --> 0 (commuted 2 ways)
Fixes https://github.com/llvm/llvm-project/issues/62263

Reviewed By: nikic, RKSimon
Differential Revision: https://reviews.llvm.org/D148986
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/select_or_and.ll