Add transform (and/or (icmp eq/ne (A, C)), (icmp eq/ne (A, -C))) -> (icmp eq/ne ...
authorNoah Goldstein <goldstein.w.n@gmail.com>
Tue, 14 Feb 2023 01:39:42 +0000 (19:39 -0600)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Wed, 15 Feb 2023 00:59:04 +0000 (18:59 -0600)
commit42e11a6ea32174b322d26756450793f1d8405f08
treeb20cdf50a1d3dfb233213dca5a8b7b846430df0c
parentabf6692f951339872fa78ac7a607c4a11a12b2e2
Add transform (and/or (icmp eq/ne (A, C)), (icmp eq/ne (A, -C))) -> (icmp eq/ne (ABS A), ABS(C))

This can be beneficial if there is a fast `ABS` (For example with X86
`vpabs`) or if there is a dominating ABS(A) in the `DAG`.

Note `C` is constant so `ABS(C)` is just a constant.

Alive2 Links:
EQ: https://alive2.llvm.org/ce/z/829F-c
NE: https://alive2.llvm.org/ce/z/tsS8bU

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D142601
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-abs-C-vec.ll
llvm/test/CodeGen/X86/icmp-abs-C.ll