combine, amdgcn: Fix ICE truncating wide vectors; allow packed accesses [PR122583]
Fixes an ICE in the combine pass related to truncating wide vectors and allows packed accesses on GCN.
This commit resolves an ICE in the combine pass on the AMD GCN backend that occurred when truncating wide vectors. The issue stemmed from assumptions about vector register subdivision. By fixing gen_lowpart_or_truncate to handle cases where no suitable integer mode exists, the ICE is avoided. This also allows GCN to correctly handle misaligned vector accesses, resolving issues like PR122583.
In Details
The GCN backend previously disallowed misaligned vector accesses due to an ICE in the combine pass when dealing with packed structs. The ICE occurred in force_to_mode's call to gen_lowpart_or_truncate when truncating a wide vector (V4DI) to a narrow integer mode (SI). GCN lacks integer modes wider than TImode, causing int_mode_for_mode to fail. This patch modifies gen_lowpart_or_truncate to return (clobber (const_int 0)) in such cases, allowing the combination to fail cleanly and removing the workaround that hindered packed accesses.
- ICE
- Internal Compiler Error, a condition where the compiler encounters an unexpected internal state and terminates.
- combine pass
- A compiler optimization pass that combines sequences of RTL (Register Transfer Language) operations into more efficient forms.
- amdgcn
- The GCC backend for AMD's Graphics Core Next (GCN) architecture, used for GPGPU computation.
- subreg
- A subregister, which refers to a part of a larger register. In this context, it relates to accessing parts of vector registers.
- packed structs
- Struct data types where members are laid out contiguously in memory with no padding, potentially leading to misaligned data.
- RTL
- Register Transfer Language, an intermediate representation used by GCC.
- gen_lowpart_or_truncate
- An RTL function used to truncate or extract the lower part of an operand.
- V4DI
- A vector data type containing 4 doubleword (64-bit) elements.
- SImode
- GCC's internal mode for a single integer (typically 32-bit).