Fix complex number propagation to handle abnormal definitions correctly
Correctly propagates lattice values for complex numbers, including handling abnormal definitions.
This commit fixes an issue in GCC’s complex number optimization pass where abnormal definitions were ignored during analysis, leading to incorrect lattice value propagation. The fix ensures that abnormal definitions are properly handled by setting their lattice value to VARYING. This correction improves the accuracy of complex number propagation, allowing for more effective optimizations related to complex types.
In Details
This patch addresses PR tree-optimization/128464 by correcting the handling of abnormal definitions within the complex_propagate pass. Previously, abnormal definitions were ignored during the analysis phase, meaning their lattice values were not propagated. The fix modifies complex_propagate::visit_stmt and complex_propagate::visit_phi to set the lattice value of abnormal definitions to VARYING, ensuring that the analysis correctly accounts for potential variations in complex number values.
- Complex number propagation
- A compiler optimization technique that tracks the possible values of complex numbers throughout the program to enable further optimizations.
- lattice value
- A value within a lattice data structure used in compiler analysis to represent the possible states or properties of a program element (e.g., a variable's value).
- VARYING
- A lattice value indicating that a variable can take on multiple possible values, making its exact state uncertain for optimization purposes.
- abnormal definition
- In the context of compiler analysis, a definition that cannot be precisely determined or tracked, possibly due to complex control flow or external influences.
- visit_stmt
- A method within a compiler's analysis pass that is called to process a specific statement in the intermediate representation.
- visit_phi
- A method within a compiler's analysis pass that is called to process a PHI node, which represents control flow merging in SSA form.