| Issue |
242594
|
| Summary |
[AMDGPU][R600] A debug use prevents vector register merging
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
yqtian-se
|
Compiling this function with `-g` splits the ALU clause and exports the second
value from `T1.X` instead of `T0.Y`.
```c
typedef float v4f __attribute__((vector_size(16)));
extern void export(v4f, int, int) __asm__("llvm.r600.store.swizzle");
void main(v4f a) {
float x = a[0] + 1.5f;
float y = a[1] + 1.5f;
v4f first = {x, y, a[2], a[3]};
v4f second = {y, 0.0f, 0.0f, 0.0f};
export(first, 0, 0);
export(second, 1, 0);
}
```
```sh
clang --target=r600 -mcpu=cayman -ffreestanding -O1 -g \
-S input.c -o with-g.s
clang --target=r600 -mcpu=cayman -ffreestanding -O1 -g0 \
-S input.c -o without-g.s
diff -u without-g.s with-g.s
```
The relevant difference is:
```diff
- EXPORT T0.Y000
+ EXPORT T1.X000
```
The first difference appears in `vec-merger`. `areAllUsesSwizzeable` iterates
`use_instructions(Reg)`, which includes `DBG_VALUE`. `canSwizzle` rejects that
debug instruction, so the debug use prevents the register merge.
Debug uses should not block this optimization. This was reproduced with clang
`7517bcdb0b87`; the responsible code remains unchanged on LLVM main
`2451a1eadfa1`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs