rs6000: Set length for P10 fusion TOC patterns
Fix assembler errors on POWER10 by correctly sizing TOC patterns.
POWER10’s Table of Contents (TOC) patterns, used for large functions, were incorrectly sized. These patterns, which expand to two instructions, inherited a default length of four bytes instead of their actual eight. This underestimation caused the branch shortening logic to miscalculate distances to labels, leading to conditional branches being emitted as short branches. This resulted in assembler errors when branches fell outside the +/-32KB range, particularly with -mtune=power10. The fix sets the length of these four patterns to eight bytes, resolving the assembler errors.
In Details
The largetocp10 patterns in rs6000.md were missing a length attribute. These patterns generate two instructions for TOC (Table of Contents) address materialization on POWER10. The assembler uses instruction lengths to calculate branch distances. By defaulting to 4 bytes, shorten_branches underestimated offsets, leading to incorrect short branch emission when fusion was enabled via -mtune=power10. Setting the length to 8 bytes corrects this distance calculation.
- TOC (Table of Contents)
- In this context, refers to a mechanism for accessing global data or functions, often involving special instructions for address generation.
- POWER10 fusion
- A feature on POWER10 processors that combines multiple instructions into a single, more efficient micro-operation. Enabled via the -mtune=power10 flag.
- shorten_branches
- A compiler optimization pass that attempts to replace longer conditional branch instructions with shorter, more efficient ones when the target is within a limited range.