GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
tree-optimization

tree-optimization: Fix profile update in loop splitting (initial_true=false)

Fixes a bug in loop splitting that caused incorrect profile updates when the loop guard condition is inverted.

A bug in loop splitting’s profile update logic has been fixed. When the loop splitting process inverts the guard condition of a loop (e.g., changing t < i to i > t), the profile update code was using incorrect edge probabilities. This resulted in inaccurate BB counts and iteration estimates for the split loops, especially when the initial_true flag was false. The fix ensures that profile quantities are correctly associated with the semantic edges of the split loops.

In Details

The patch addresses an issue in tree-ssa-loop-split.cc, specifically in the split_loop function, which performs iteration space splitting. The bug was related to profile update when the guard condition is swapped, resulting in initial_true being false. The fix ensures that loop1_edge and loop2_edge are derived correctly from initial_true and used consistently for loop1_prob, fix_loop_bb_probability, and iteration estimate scaling.

For Context

Loop splitting is a compiler optimization technique that divides a loop into multiple versions, each handling a subset of the original iteration space. This allows the compiler to optimize each version more effectively based on different conditions. This commit fixes a bug in how the compiler tracks the execution frequency (profile) of these split loops, ensuring that the performance data is accurate even when the loop's condition is inverted. Accurate profiling helps the compiler make better optimization decisions.

Filed Under: optimizationloop splittingbugfixprofiling