Refactor match-op to nary-op initialization for VN lookup.
Simplifies initialization of VN lookup structures by factoring out common logic for match-op.
This change refactors the initialization of VN lookup structures in the tree-optimization subsystem. It factors out helper functions for initializing vn_nary_op from gimple_match_op structures. This simplifies the vn_lookup_simplify_result function by using these new helpers, making the code cleaner and easier to maintain. The change is motivated by PR tree-optimization/128651.
In Details
In tree-ssa-sccvn.cc, this commit introduces helper functions match_op_generic_constructor_p, vn_nary_length_from_match_op, and init_vn_nary_op_from_match_op. These helpers streamline the process of creating vn_nary_op structures from gimple_match_op inputs, specifically within the context of SCCVN (Strongly Connected Components based Value Numbering). The vn_lookup_simplify_result function is updated to use these new helpers, improving the initialization logic for lookup nary ops. This addresses PR tree-optimization/128651.
- VN lookup
- Value Numbering lookup is a compiler optimization technique used to identify and eliminate redundant computations by assigning a unique number (value number) to each distinct expression. A VN lookup helps in finding existing value numbers for newly encountered expressions.
- n-ary operation
- An n-ary operation is a computational operation that takes 'n' operands. In the context of compilers, it often refers to operations with multiple arguments or components, such as function calls or complex expressions.
- gimple_match_op
- A GIMPLE construct representing a match operation. GIMPLE is an intermediate representation used by GCC.
gimple_match_oplikely pertains to pattern matching within the GIMPLE representation for optimization purposes. - tree-optimization
- A phase in the GCC compiler that operates on the 'tree' intermediate representation. It performs various optimizations like constant folding, dead code elimination, and loop optimizations before code generation.
- SCCVN
- Strongly Connected Components based Value Numbering. A value numbering technique that leverages graph theory, specifically strongly connected components, to analyze and optimize code, often used for detecting and eliminating redundant computations within loops or mutually recursive code.