xtensa: Implement xtensa_rtl_combine_reached_p() predicate function
Introduces a new predicate function to control instruction combination optimization based on scratch register usage.
This commit introduces xtensa_rtl_combine_reached_p(), a target-specific predicate function, to refine instruction combination optimizations in the Xtensa architecture. It aims to improve optimization opportunities by differentiating between early-stage RTL passes that benefit from constant-value scratch registers and later instruction combination passes where such registers might hinder optimization. This addresses an issue where non-standard instruction patterns could lead to unintended optimization outcomes.
In Details
The Xtensa backend now has a target-specific predicate function, xtensa_rtl_combine_reached_p(), which influences the instruction combination pass. This predicate is designed to control whether the recognizer attempts to match patterns that use constant-value scratch registers. The goal is to allow optimizations like CSE and loop-invariant hoisting to be effective by avoiding scratch registers in patterns that are recognized later in the optimization pipeline, particularly in the instruction combination phase, while still permitting their use in earlier RTL generation.
- RTL
- Register Transfer Language, an intermediate representation used by GCC between the high-level language and the machine code. It represents operations on virtual registers.
- CSE
- Common Subexpression Elimination, an optimization that replaces multiple identical expressions with a single variable holding the result.
- MD pattern
- Macro definition pattern used in GCC's configuration files to describe machine instructions and their properties for code generation.
- define_expand
- A type of MD pattern in GCC that describes how to generate RTL for a high-level construct that doesn't map directly to a single machine instruction.
- define_insn_and_split
- An MD pattern that describes a machine instruction and how to split it into simpler instructions if it cannot be generated directly.