[InstCombine] Canonicalize `(icmp eq/ne (and x, C), x)` -> `(icmp eq/ne (and x, ...
authorNoah Goldstein <goldstein.w.n@gmail.com>
Thu, 29 Jun 2023 07:37:23 +0000 (02:37 -0500)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Thu, 29 Jun 2023 18:14:37 +0000 (13:14 -0500)
commit13f16f4dea14a5efc4d471e02317b8ffb77a0896
tree804e1ccf5fd011ed3dc1ba7118f2a6fa133af8b1
parent9595a18de12685fdadda6fb432f6b464e046275f
[InstCombine] Canonicalize `(icmp eq/ne (and x, C), x)` -> `(icmp eq/ne (and x, ~C), 0)`

This increases the likelyhood `x` is single-use and is typically
easier to analyze.

Proofs: https://alive2.llvm.org/ce/z/8ZpS2W

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D154004
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll
llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll
llvm/test/Transforms/InstCombine/icmp-logical.ll
llvm/test/Transforms/InstCombine/select.ll