This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: PATCH: testsuite/37074: gcc.dg/torture/stackalign/builtin-apply-4.c failed with SSE2


HJ wrote:
>On Mon, Aug 11, 2008 at 11:37 PM, Ye, Joey <joey.ye@intel.com> wrote:
>> Em, it won't violate the rules as long as EMMS is executed before
>> function entry and exit, right?
>>
>
> Can you give it a try?
Following patch fixes builtin-apply-4.c. But the changes in i386.md is
ugly and inefficient, which insert EMMS after every mmx movd insn. Any
suggestion?

- Joey
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c      (revision 138935)
+++ gcc/builtins.c      (working copy)
@@ -1589,6 +1589,7 @@ expand_builtin_return (rtx result)
   enum machine_mode mode;
   rtx reg;
   rtx call_fusage = 0;
+  int size_array[FIRST_PSEUDO_REGISTER];
 
   result = convert_memory_address (Pmode, result);
 
@@ -1604,7 +1605,7 @@ expand_builtin_return (rtx result)
     }
 #endif
 
-  /* Restore the return value and note that each value is used.  */
+  /* Calculate offset of return value and stores in array for later
use. */
   size = 0;
   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
     if ((mode = apply_result_mode[regno]) != VOIDmode)
@@ -1612,14 +1613,25 @@ expand_builtin_return (rtx result)
        align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
        if (size % align != 0)
          size = CEIL (size, align) * align;
+       size_array[regno] = size;
+       size += GET_MODE_SIZE (mode);
+      }
+    else
+      size_array[regno] = -1;
+
+  /* Restore the return value and note that each value is used. 
+     Insns are emitted in the reversed sequence to solve MMX messing up
+     FPU problem in IA32 backend. */
+  for (regno = FIRST_PSEUDO_REGISTER - 1; regno >=0; regno--)
+    if ((mode = apply_result_mode[regno]) != VOIDmode)
+      {
        reg = gen_rtx_REG (mode, INCOMING_REGNO (regno));
-       emit_move_insn (reg, adjust_address (result, mode, size));
+       emit_move_insn (reg, adjust_address (result, mode,
size_array[regno]));
 
        push_to_sequence (call_fusage);
        emit_use (reg);
        call_fusage = get_insns ();
        end_sequence ();
-       size += GET_MODE_SIZE (mode);
       }
 
   /* Put the USE insns before the return.  */
Index: gcc/config/i386/i386.md
===================================================================
--- gcc/config/i386/i386.md     (revision 138935)
+++ gcc/config/i386/i386.md     (working copy)
@@ -2223,8 +2223,8 @@
    #
    #
    pxor\t%0, %0
-   movq\t{%1, %0|%0, %1}
-   movq\t{%1, %0|%0, %1}
+   movq\t{%1, %0|%0, %1}\n\temms
+   movq\t{%1, %0|%0, %1}\n\temms
    pxor\t%0, %0
    movq\t{%1, %0|%0, %1}
    movdqa\t{%1, %0|%0, %1}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]