gcc/
authorYvan Roux <yvan.roux@linaro.org>
Sat, 3 Sep 2016 17:11:59 +0000 (19:11 +0200)
committerYvan Roux <yvan.roux@linaro.org>
Wed, 7 Sep 2016 20:08:31 +0000 (22:08 +0200)
Backport from trunk r237277.
2016-06-09  Vladimir Makarov  <vmakarov@redhat.com>
    Jiong Wang  <jiong.wang@arm.com>

PR rtl-optimization/70751
* lra-constraints.c (process_alt_operands): Recognize Non-pseudo spilled
into memory.

Change-Id: Id1d56eb327c732269a959b940639656756d56a96

gcc/lra-constraints.c

index ec25e75..bcffea5 100644 (file)
@@ -2467,14 +2467,27 @@ process_alt_operands (int only_alternative)
              /* We are trying to spill pseudo into memory.  It is
                 usually more costly than moving to a hard register
                 although it might takes the same number of
-                reloads.  */
-             if (no_regs_p && REG_P (op) && hard_regno[nop] >= 0)
+                reloads.
+
+                Non-pseudo spill may happen also.  Suppose a target allows both
+                register and memory in the operand constraint alternatives,
+                then it's typical that an eliminable register has a substition
+                of "base + offset" which can either be reloaded by a simple
+                "new_reg <= base + offset" which will match the register
+                constraint, or a similar reg addition followed by further spill
+                to and reload from memory which will match the memory
+                constraint, but this memory spill will be much more costly
+                usually.
+
+                Code below increases the reject for both pseudo and non-pseudo
+                spill.  */
+             if (no_regs_p && !(REG_P (op) && hard_regno[nop] < 0))
                {
                  if (lra_dump_file != NULL)
                    fprintf
                      (lra_dump_file,
-                      "            %d Spill pseudo into memory: reject+=3\n",
-                      nop);
+                      "            %d Spill %spseudo into memory: reject+=3\n",
+                      nop, REG_P (op) ? "" : "Non-");
                  reject += 3;
                  if (VECTOR_MODE_P (mode))
                    {