[GlobalISel] Combine (logic_op (op x...), (op y...)) -> (op (logic_op x, y))
authorJessica Paquette <jpaquette@apple.com>
Mon, 10 Aug 2020 20:31:41 +0000 (13:31 -0700)
committerJessica Paquette <jpaquette@apple.com>
Tue, 11 Aug 2020 17:40:06 +0000 (10:40 -0700)
commitbebe6a6449811e877f7eba3f1798ddd1fa83e440
tree996212054de6b1885739c35f8335049c7adf2428
parentd2c18b598359f9b59314669ccd15070d07aeb68a
[GlobalISel] Combine (logic_op (op x...), (op y...)) -> (op (logic_op x, y))

This implements

```
(logic_op (op x...), (op y...)) -> (op (logic_op x, y))
```

when `op` is an extend, a shift, or an and.

This is similar to `DAGCombiner::hoistLogicOpWithSameOpcodeHands`
(with a bunch of missing cases, e.g. G_TRUNC, G_BITCAST, etc.)

This is implemented so it works both pre and post-legalization.

This also adds a general way to add a series of instructions in a combine.
(`applyBuildInstructionSteps`).

Differential Revision: https://reviews.llvm.org/D85050
llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
llvm/include/llvm/Target/GlobalISel/Combine.td
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/lib/Target/AArch64/AArch64Combine.td
llvm/test/CodeGen/AArch64/GlobalISel/postlegalizercombiner-hoist-same-hands.mir [new file with mode: 0644]
llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-hoist-same-hands.mir [new file with mode: 0644]