ira-costs.c (find_costs_and_classes): For -O0...
authorRichard Sandiford <rdsandiford@googlemail.com>
Sat, 26 Jul 2014 09:48:24 +0000 (09:48 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Sat, 26 Jul 2014 09:48:24 +0000 (09:48 +0000)
gcc/
* ira-costs.c (find_costs_and_classes): For -O0, use the best class
as the allocation class if it isn't likely to be spilled.

From-SVN: r213078

gcc/ChangeLog
gcc/ira-costs.c

index 6cf53647c62ef2fe25085d56ad534852e631f108..17506913c1d03c6860e4bc4cc17c402c0d34a5f4 100644 (file)
@@ -1,3 +1,8 @@
+2014-07-26  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * ira-costs.c (find_costs_and_classes): For -O0, use the best class
+       as the allocation class if it isn't likely to be spilled.
+
 2014-07-26  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * rtl.h (tls_referenced_p): Declare.
index a83e1dff00c76124ddae7f62af7944ce09590318..13bbf077829fa152858ff60d7bddfd614eee0410 100644 (file)
@@ -1753,6 +1753,20 @@ find_costs_and_classes (FILE *dump_file)
          alt_class = ira_allocno_class_translate[alt_class];
          if (best_cost > i_mem_cost)
            regno_aclass[i] = NO_REGS;
+         else if (!optimize && !targetm.class_likely_spilled_p (best))
+           /* Registers in the alternative class are likely to need
+              longer or slower sequences than registers in the best class.
+              When optimizing we make some effort to use the best class
+              over the alternative class where possible, but at -O0 we
+              effectively give the alternative class equal weight.
+              We then run the risk of using slower alternative registers
+              when plenty of registers from the best class are still free.
+              This is especially true because live ranges tend to be very
+              short in -O0 code and so register pressure tends to be low.
+
+              Avoid that by ignoring the alternative class if the best
+              class has plenty of registers.  */
+           regno_aclass[i] = best;
          else
            {
              /* Make the common class the biggest class of best and