[SDAG] try to convert bit set/clear to signbit test when trunc is free
authorSanjay Patel <spatel@rotateright.com>
Tue, 6 Dec 2022 16:17:52 +0000 (11:17 -0500)
committerSanjay Patel <spatel@rotateright.com>
Tue, 6 Dec 2022 16:34:48 +0000 (11:34 -0500)
commitadc7c589c3dd35af5991ee481fa4667094bca548
tree3377b8da2b6564fb08c488b20312860eb4b1627d
parent772c2f461b942032df8426a49077c37066783a68
[SDAG] try to convert bit set/clear to signbit test when trunc is free

(X & Pow2MaskC) == 0 --> (trunc X) >= 0
(X & Pow2MaskC) != 0 --> (trunc X) <  0

This was noted as a regression in the post-commit feedback for D112634
(where we canonicalized IR differently).

For x86, this saves a few instruction bytes. AArch64 seems neutral.

Differential Revision: https://reviews.llvm.org/D139363
14 files changed:
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/AArch64/signbit-test.ll
llvm/test/CodeGen/X86/btq.ll
llvm/test/CodeGen/X86/masked_compressstore.ll
llvm/test/CodeGen/X86/masked_expandload.ll
llvm/test/CodeGen/X86/masked_gather.ll
llvm/test/CodeGen/X86/masked_load.ll
llvm/test/CodeGen/X86/masked_store.ll
llvm/test/CodeGen/X86/masked_store_trunc.ll
llvm/test/CodeGen/X86/masked_store_trunc_ssat.ll
llvm/test/CodeGen/X86/masked_store_trunc_usat.ll
llvm/test/CodeGen/X86/omit-urem-of-power-of-two-or-zero-when-comparing-with-zero.ll
llvm/test/CodeGen/X86/signbit-test.ll
llvm/test/CodeGen/X86/test-vs-bittest.ll