| Issue |
164961
|
| Summary |
[GlobalISel] Tablegen combines are not commutative
|
| Labels |
|
| Assignees |
|
| Reporter |
mbrkusanin
|
For example following pattern from `llvm/include/llvm/Target/GlobalISel/Combine.td` will match for first test bellow but not second which commutes operands on the last G_ADD
```
// fold (A+(B-(A+C))) to (B-C)
def APlusBMinusAplusC : GICombineRule<
(defs root:$root),
(match (G_ADD $add1, $A, $C),
(G_SUB $sub1, $B, $add1),
(G_ADD $root, $A, $sub1)),
(apply (G_SUB $root, $B, $C))>;
```
```$ llc -march=amdgcn -mcpu=gfx1200 -o - -run-pass=amdgpu-prelegalizer-combiner test.mir```
test.mir:
```
---
name: test
body: |
bb.1:
liveins: $vgpr0, $vgpr1, $vgpr2
%A:_(s32) = COPY $vgpr0
%B:_(s32) = COPY $vgpr1
%C:_(s32) = COPY $vgpr2
%add1:_(s32) = G_ADD %A, %C
%sub1:_(s32) = G_SUB %B, %add1
%root:_(s32) = G_ADD %A, %sub1
$vgpr0 = COPY %root(s32)
SI_RETURN implicit $vgpr0
...
---
name: test_rev
body: |
bb.1:
liveins: $vgpr0, $vgpr1, $vgpr2
%A:_(s32) = COPY $vgpr0
%B:_(s32) = COPY $vgpr1
%C:_(s32) = COPY $vgpr2
%add1:_(s32) = G_ADD %A, %C
%sub1:_(s32) = G_SUB %B, %add1
%root:_(s32) = G_ADD %sub1, %A
$vgpr0 = COPY %root(s32)
SI_RETURN implicit $vgpr0
...
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs