Commit 114c131
Automerge: [DAGCombiner] Add sra-xor-sra pattern fold (#166777)
Add `fold (sra (xor (sra x, c1), -1), c2) -> (sra (xor x, -1), c3)`
The IR like this:
```
%a = ashr i8 %x, 6
%n = xor i8 %a, -1
%s = sext i8 %n to i16
%r = and i16 %s, %y
ret i16 %r
```
llvm will produce:
```
slli a0, a0, 56
srai a0, a0, 56
not a0, a0
srai a0, a0, 6
and a0, a0, a1
ret
```
56 and 6 can be add up
alive2: https://alive2.llvm.org/ce/z/yxRQf9
---------
Co-authored-by: rez5427 <[email protected]>File tree
2 files changed
+48
-0
lines changed- llvm
- lib/CodeGen/SelectionDAG
- test/CodeGen/RISCV
2 files changed
+48
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10988 | 10988 | | |
10989 | 10989 | | |
10990 | 10990 | | |
| 10991 | + | |
| 10992 | + | |
| 10993 | + | |
| 10994 | + | |
| 10995 | + | |
| 10996 | + | |
| 10997 | + | |
| 10998 | + | |
| 10999 | + | |
| 11000 | + | |
| 11001 | + | |
| 11002 | + | |
| 11003 | + | |
| 11004 | + | |
| 11005 | + | |
| 11006 | + | |
10991 | 11007 | | |
10992 | 11008 | | |
10993 | 11009 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
0 commit comments