| Issue |
175596
|
| Summary |
[AMDGPU] Lowering REG_SEQUENCE with undef operands results in "Bad machine code: No live subrange at use"
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
kezada94
|
When lowering `REG_SEQUENCE` into `COPY` instr, the compiler skip unnecessary `COPY` inst if the source operand is marked as `undef`. The current implementation doesn’t account for future uses of the skipped sub-register, which may result in a `use without def` situation which can propagate into bad machine code in some targets.
The following test case demonstrates the issue:
```
# RUN: llc -mtriple=amdgcn-amd-amdhsa -start-before=twoaddressinstruction -verify-coalescing -o - %s | FileCheck %s
---
name: test
tracksRegLiveness: true
body: |
bb.0:
%0:sgpr_32 = S_MOV_B32 0, implicit $exec
%3:sreg_64 = REG_SEQUENCE %0:sgpr_32, %subreg.sub0, undef %2:sgpr_32, %subreg.sub1
%12:vgpr_32 = V_MOV_B32_e32 %3.sub1:sreg_64, implicit $exec
...
```
Outputs:
```
*** Bad machine code: No live subrange at use ***
- function: test
- basic block: %bb.0 (0x57ed02586648) [0B;64B)
- instruction: 48B dead %3:vgpr_32 = V_MOV_B32_e32 %1.sub1:sreg_64, implicit $exec
- operand 1: %1.sub1:sreg_64
- interval: %1 [32r,48r:0) 0@32r L0000000000000003 [32r,32d:0) 0@32r weight:0.000000e+00
- at: 48B
LLVM ERROR: Found 1 machine code errors.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
```
This can be avoided by propagating the `undef` flag, or simply not skipping the `COPY` instr if there are uses for that sub-register.
A proposal fix is in: XXXXX
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs