re PR rtl-optimization/37263 (extra code for doloop with unsigned 32bit types on...
[gcc.git] / gcc / tree-ssa-loop-ivopts.c
index 341f41cea52215e78d4bd92cb9420e47c649eac5..4639588a162b390aef008f0e90f71192d16f9c63 100644 (file)
@@ -3880,8 +3880,8 @@ determine_use_iv_cost_condition (struct ivopts_data *data,
   fd_ivopts_data = data;
   walk_tree (&cmp_iv->base, find_depends, &depends_on_express, NULL);
 
-  /* Choose the better approach */
-  if (compare_costs (elim_cost, express_cost) < 0)
+  /* Choose the better approach, preferring the eliminated IV. */
+  if (compare_costs (elim_cost, express_cost) <= 0)
     {
       cost = elim_cost;
       depends_on = depends_on_elim;