Add Transform for `(and/or (eq/ne A,Pow2),(eq/ne A,-Pow2))`->`(eq/ne (and (and A...
authorNoah Goldstein <goldstein.w.n@gmail.com>
Tue, 14 Feb 2023 01:40:35 +0000 (19:40 -0600)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Wed, 15 Feb 2023 00:59:04 +0000 (18:59 -0600)
commit54a9e992c84cc4b1668329494f4355e7d0b8e470
treefde7202e479eca304585caaf1bd4ab5588354173
parente29c4393236fae95c57b9eb631a806ff47dc38cd
Add Transform for `(and/or (eq/ne A,Pow2),(eq/ne A,-Pow2))`->`(eq/ne (and (and A,Pow2),~(Pow2*2)), 0)`

In many instances this can be preferable if the `icmp` -> `i1` cannot be
done in one instruction (such as X86 for scalars).

At the moment guarded behind `TLI.isDesirableToCombineLogicOpOfSETCC`.

alive2 links:
https://alive2.llvm.org/ce/z/nLm5sN
https://alive2.llvm.org/ce/z/moEcyE

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D142344
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/test/CodeGen/X86/icmp-pow2-logic-npow2.ll