https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93004
Bug ID: 93004 Summary: Suspicious code in tree-ssa-loop-ivopts.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: --- In function determine_group_iv_cost_address(), /* Uses in a group can share setup code, so only add setup cost once. */ cost -= cost.scratch; /* Compute and add costs for rest uses of this group. */ for (i = 1; i < group->vuses.length () && !sum_cost.infinite_cost_p (); i++) { struct iv_use *next = group->vuses[i]; /* TODO: We could skip computing cost for sub iv_use when it has the same cost as the first iv_use, but the cost really depends on the offset and where the iv_use is. */ cost = get_computation_cost (data, next, cand, true, NULL, &can_autoinc, &inv_expr); if (inv_expr) { if (!inv_exprs) inv_exprs = BITMAP_ALLOC (NULL); bitmap_set_bit (inv_exprs, inv_expr->id); } sum_cost += cost; } Change to "cost" ahead of loop is meaningless, since it will be refreshed inside the loop. According to comment, I guess "cost -= cost.scratch" might be placed after "cost = get_computation_cost()".