[DAGCombiner] Hoist funnel shifts from logic operation
authorFilipp Zhinkin <filipp.zhinkin@gmail.com>
Fri, 5 Aug 2022 20:56:45 +0000 (16:56 -0400)
committerSanjay Patel <spatel@rotateright.com>
Fri, 5 Aug 2022 21:02:22 +0000 (17:02 -0400)
commitc55899f763b6d4510fd77711af3b605fd444e7fa
treededfe8bb9c8639076cdbde2e1536bd587e790dd7
parent8ac015caf627a0db89540950d6343e955ba9500b
[DAGCombiner] Hoist funnel shifts from logic operation

Hoist funnel shift from logic op:
logic_op (FSH x0, x1, s), (FSH y0, y1, s) --> FSH (logic_op x0, y0), (logic_op x1, y1), s

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

Reduced amount of funnel shifts can also improve throughput on x86 CPUs by utilizing more
available ports: https://quick-bench.com/q/gC7AKkJJsDZzRrs_JWDzm9t_iDM

Transformation correctness checks:
https://alive2.llvm.org/ce/z/TKPULH
https://alive2.llvm.org/ce/z/UvTd_9
https://alive2.llvm.org/ce/z/j8qW3_
https://alive2.llvm.org/ce/z/7Wq7gE
https://alive2.llvm.org/ce/z/Xr5w8R
https://alive2.llvm.org/ce/z/D5xe_E
https://alive2.llvm.org/ce/z/2yBZiy

Differential Revision: https://reviews.llvm.org/D130994
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/funnel-shift-logic-fold.ll
llvm/test/CodeGen/X86/icmp-shift-opt.ll