http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56195



--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-02-07 
20:02:20 UTC ---

Actually, that one doesn't really work, because we have pseudo rather than hard

reg at that point, which will never simplify.



With this:



--- lra-constraints.c.jj    2013-02-07 18:34:39.000000000 +0100

+++ lra-constraints.c    2013-02-07 20:58:25.558920536 +0100

@@ -421,8 +421,20 @@ get_reload_reg (enum op_type type, enum

       if (rtx_equal_p (curr_insn_input_reloads[i].input, original)

       && in_class_p (curr_insn_input_reloads[i].reg, rclass, &new_class))

     {

-      *result_reg = curr_insn_input_reloads[i].reg;

-      regno = REGNO (*result_reg);

+      rtx reg = curr_insn_input_reloads[i].reg;

+      regno = REGNO (reg);

+      /* If input is equal to original and both are VOIDmode,

+         GET_MODE (reg) might be still different from mode.

+         Ensure we don't return *result_reg with wrong mode.  */

+      if (GET_MODE (reg) != mode)

+        {

+          if (GET_MODE_SIZE (GET_MODE (reg)) < GET_MODE_SIZE (mode))

+        continue;

+          reg = lowpart_subreg (mode, reg, GET_MODE (reg));

+          if (reg == NULL_RTX || GET_CODE (reg) != SUBREG)

+        continue;

+        }

+      *result_reg = reg;

       if (lra_dump_file != NULL)

         {

           fprintf (lra_dump_file, "     Reuse r%d for reload ", regno);



the assembly difference is:



-    cmpl    (%rdi), %rdi

+    cmpl    (%rdi), %edi



which is desirable in this case, but not sure if all get_reload_reg callers

will grok a SUBREG instead of REG returned in *result_reg.

Reply via email to