https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92862
Bug ID: 92862 Summary: Suspicious codes in tree-ssa-loop-niter.c and predict.c Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: fxue at os dot amperecomputing.com Target Milestone: --- Function loop_only_exit_p() in tree-ssa-loop-niter.c: for (i = 0; i < loop->num_nodes; i++) { for (bsi = gsi_start_bb (body[i]); !gsi_end_p (bsi); gsi_next (&bsi)) if (stmt_can_terminate_bb_p (gsi_stmt (bsi))) { return true; } } we should return false, not true? Function predict_paths_leading_to_edge() in predict.c: FOR_EACH_EDGE (e2, ei, bb->succs) if (e2->dest != e->src && e2->dest != e->dest && !unlikely_executed_edge_p (e) && !dominated_by_p (CDI_POST_DOMINATORS, e->src, e2->dest)) { has_nonloop_edge = true; break; } "e" is loop invariant, I guess that unlikely_executed_edge_p (e) might be unlikely_executed_edge_p (e2), which is more reasonable. And we can find similar code in predict_paths_for_bb () that uses the latter.