[GlobalISel] Combine (x op 0) -> x for operations with a right identity of 0
authorJessica Paquette <jpaquette@apple.com>
Mon, 23 Mar 2020 20:14:10 +0000 (13:14 -0700)
committerJessica Paquette <jpaquette@apple.com>
Mon, 30 Mar 2020 23:49:52 +0000 (16:49 -0700)
commit63d70ea6a07131587e09914176551f4437187f78
tree81acf0f82e5b1639ec4132df6178eca0d01834e7
parentcf36f9855a7b8a7e69416b8d20c999a28c73b1b2
[GlobalISel] Combine (x op 0) -> x for operations with a right identity of 0

Implement identity combines for operations like the following:

```
%a = G_SUB %b, 0
```

This can just be replaced with %b.

Over CTMark, this gives some minor size improvements at -O3.

Differential Revision: https://reviews.llvm.org/D76640
llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
llvm/include/llvm/Target/GlobalISel/Combine.td
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-trivial-arith.mir [new file with mode: 0644]