Preserve edge flags in cleanup_control_expr_graph.
The cleanup_control_expr_graph function now preserves edge flags like EDGE_IRREDUCIBLE_LOOP, instead of clearing them unintentionally.
The cleanup_control_expr_graph function was clearing all edge flags, including EDGE_IRREDUCIBLE_LOOP, when setting EDGE_FALLTHRU. It now only clears EDGE_TRUE_VALUE and EDGE_FALSE_VALUE, preserving other important flags. A new testcase, gcc.dg/torture/pr125156.c, was added to ensure the correct behavior.
In Details
cleanup_control_expr_graph is a function in tree-cfgcleanup.cc responsible for cleaning up the control flow graph (CFG) representation in GCC's middle-end. The CFG uses edge flags to mark various properties of edges between basic blocks. This commit fixes a bug where flags like EDGE_IRREDUCIBLE_LOOP were being cleared unintentionally, potentially affecting loop optimizations or other analyses that rely on these flags. The fix ensures that only the flags related to conditional execution (EDGE_TRUE_VALUE and EDGE_FALSE_VALUE) are cleared.
For Context
In a compiler, the control flow graph (CFG) represents how the program's execution flows through different blocks of code. Edges in this graph can have flags that indicate specific properties, such as whether a loop is irreducible (meaning it has complex control flow). This commit fixes a bug where the compiler was incorrectly clearing these flags during a cleanup process, potentially disrupting later optimization stages that rely on this information. This ensures the compiler maintains an accurate model of program control flow.