[DAGCombine] Hoist shifts out of a logic operations tree.
authorFilipp Zhinkin <filipp.zhinkin@gmail.com>
Thu, 4 Aug 2022 18:34:15 +0000 (21:34 +0300)
committerFilipp Zhinkin <filipp.zhinkin@gmail.com>
Fri, 12 Aug 2022 09:42:16 +0000 (12:42 +0300)
commit1626ee6a9581be98d4a2dc251524ad6dc2725696
treee48330a5ecfe8bf11b3bd545a8d4887dcf1a0767
parenta6bf6f25f070b92ecb50465f6a270671d30e459a
[DAGCombine] Hoist shifts out of a logic operations tree.

Hoist and combine shift operations from logic operations tree:
logic (logic (SH x0, s), y), (logic (SH x1, s), z)  --> logic (SH (logic x0, x1), s), (logic y, z)

The transformation improves code generated for some cases related to the issue https://github.com/llvm/llvm-project/issues/49541.

Correctness:
https://alive2.llvm.org/ce/z/pVqVgY
https://alive2.llvm.org/ce/z/YVvT-q
https://alive2.llvm.org/ce/z/W5zTBq
https://alive2.llvm.org/ce/z/YfJsvJ
https://alive2.llvm.org/ce/z/3YSyDM
https://alive2.llvm.org/ce/z/Bs2kzk
https://alive2.llvm.org/ce/z/EoQpzU
https://alive2.llvm.org/ce/z/Jnc_5H
https://alive2.llvm.org/ce/z/_LP6k_
https://alive2.llvm.org/ce/z/KvZNC9

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D131189
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/ARM/icmp-shift-opt.ll
llvm/test/CodeGen/ARM/shift-combine.ll
llvm/test/CodeGen/PowerPC/p10-handle-split-promote-vec.ll
llvm/test/CodeGen/X86/bswap_tree2.ll
llvm/test/CodeGen/X86/shift-combine.ll