https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103226
Aldy Hernandez <aldyh at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org --- Comment #1 from Aldy Hernandez <aldyh at gcc dot gnu.org> --- I can't opine on the intricacies of the loopch pass, but the decision the path solver took was correct: ./cc1 a.c -fdump-tree-all-details -quiet -I/tmp -O2 --param threader-debug=all Then in the *.ch2 dump file I see: ============================================== path_range_query: compute_ranges for path: 5->12 range_defined_in_block (BB12) for h_8 is int [0, 0] =========== BB 5 ============ b.0_3 int [0, 0][5, +INF] <bb 5> [local count: 60236916]: e = 1; goto <bb 12>; [100.00%] =========== BB 12 ============ Imports: h_8 Exports: h_8 b.0_3 int [0, 0][5, +INF] <bb 12> [local count: 602369155]: # h_8 = PHI <0(5), h_11(11)> if (h_8 != 9) goto <bb 19>; [90.00%] else goto <bb 13>; [10.00%] etc. The conditional in BB12 resolves to true: loopch static returned: _Bool [1, 1] Which I got from a small tweak to the ch source: diff --git a/gcc/tree-ssa-loop-ch.c b/gcc/tree-ssa-loop-ch.c index 566cc275317..d5d80e33450 100644 --- a/gcc/tree-ssa-loop-ch.c +++ b/gcc/tree-ssa-loop-ch.c @@ -74,7 +74,14 @@ entry_loop_condition_is_static (class loop *l, path_range_query *query) int_range<2> r; query->compute_ranges (e); query->range_of_stmt (r, last); - return r == int_range<2> (desired_static_value, desired_static_value); + bool ret = (r == int_range<2> (desired_static_value, desired_static_value)); + if (ret && dump_file) + { + fprintf (dump_file, "loopch static returned: "); + r.dump(dump_file); + fprintf (dump_file, "\n"); + } + return ret; }