Fix single use checks in factor_out_operators
Corrects SSA analysis in ifcvt to properly handle single-use PHI nodes.
This commit fixes a bug in the factor_out_operators function within the ifcvt (if conversion) optimization pass. The issue involved incorrect handling of single-use PHI nodes due to a temporary hack addressing broken SSA. By removing this hack and ensuring correct SSA checks, the optimization now functions as intended, resolving a test case failure.
In Details
The ifcvt optimization pass, specifically in tree-if-conv.cc, relies on accurate Static Single Assignment (SSA) form. This patch corrects how factor_out_operators checks for single-use PHI arguments, reverting a workaround that masked an SSA issue. The fix ensures that only genuinely single-use PHI nodes are considered, aligning the pass's behavior with its original intent.
- ifcvt
- If conversion is a compiler optimization pass that transforms conditional code into equivalent code without explicit branches, often by using conditional moves or predicated operations. It aims to improve performance by reducing control flow overhead.
- SSA
- Static Single Assignment (SSA) is an intermediate representation property where every variable is assigned a value exactly once. This simplifies many compiler analyses and optimizations by making data flow explicit. SSA form is typically constructed and maintained by the compiler's front-end and middle-end passes.
- PHI node
- In SSA form, a PHI node (or Phi function) is used to merge values from different control flow paths. It takes multiple arguments, each corresponding to a predecessor block in the control flow graph, and selects the appropriate value based on which predecessor was executed.