The PHI movement penalty is bogously biased by adding the cost of moving
the condition - but the condition is computed unconditionally and thus
its cost should be added to the PHI cost.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

This patch is required to avoid regressing with a followup that will
exchange LIM and PRE (PRE can cleanup after LIM which avoids one
copyprop pass and it can perform CSE which increases vectorization
opportunities - failed to find the PR right now).

Richard.

2016-05-18  Richard Biener  <rguent...@suse.de>

        * tree-ssa-loop-im.c (determine_max_movement): Properly add
        condition cost to PHI cost instead of total_cost.

Index: gcc/tree-ssa-loop-im.c
===================================================================
--- gcc/tree-ssa-loop-im.c      (revision 236361)
+++ gcc/tree-ssa-loop-im.c      (working copy)
@@ -717,7 +717,7 @@ determine_max_movement (gimple *stmt, bo
                return false;
              def_data = get_lim_data (SSA_NAME_DEF_STMT (val));
              if (def_data)
-               total_cost += def_data->cost;
+               lim_data->cost += def_data->cost;
            }
 
          /* We want to avoid unconditionally executing very expensive

Reply via email to