[all-commits] [llvm/llvm-project] 02187e: [GlobalISel] Combine G_SELECTs of the form (cond ?...
Jessica Paquette via All-commits
all-commits at lists.llvm.org
Mon Mar 23 16:58:10 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 02187ed45a4302db5f6721c3233988fef7819701
https://github.com/llvm/llvm-project/commit/02187ed45a4302db5f6721c3233988fef7819701
Author: Jessica Paquette <jpaquette at apple.com>
Date: 2020-03-23 (Mon, 23 Mar 2020)
Changed paths:
M llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
M llvm/include/llvm/Target/GlobalISel/Combine.td
M llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
A llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-select.mir
Log Message:
-----------
[GlobalISel] Combine G_SELECTs of the form (cond ? x : x) into x
When we find something like this:
```
%a:_(s32) = G_SOMETHING ...
...
%select:_(s32) = G_SELECT %cond(s1), %a, %a
```
We can remove the select and just replace it entirely with `%a` because it's
always going to result in `%a`.
Same if we have
```
%select:_(s32) = G_SELECT %cond(s1), %a, %b
```
where we can deduce that `%a == %b`.
This implements the following cases:
- `%select:_(s32) = G_SELECT %cond(s1), %a, %a` -> `%a`
- `%select:_(s32) = G_SELECT %cond(s1), %a, %some_copy_from_a` -> `%a`
- `%select:_(s32) = G_SELECT %cond(s1), %a, %b` -> `%a` when `%a` and `%b`
are defined by identical instructions
This gives a few minor code size improvements on CTMark at -O3 for AArch64.
Differential Revision: https://reviews.llvm.org/D76523
More information about the All-commits
mailing list