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]

fix va-arg-25.c with -msse2


It seems easier to expand pushes up front for these types, rather
than after reload as with other types.


r~


        * config/i386/i386.c (ix86_expand_push): New.
        * config/i386/mmx.md (push<MMXMODE>1): New.
        * config/i386/sse.md (push<SSEMODE>1): New.
        * config/i386/i386-protos.h: Update.

Index: config/i386/i386-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386-protos.h,v
retrieving revision 1.127
diff -u -p -d -r1.127 i386-protos.h
--- config/i386/i386-protos.h	18 Jan 2005 12:01:27 -0000	1.127
+++ config/i386/i386-protos.h	20 Jan 2005 18:18:22 -0000
@@ -126,6 +126,7 @@ extern void ix86_expand_clear (rtx);
 extern void ix86_expand_move (enum machine_mode, rtx[]);
 extern void ix86_expand_vector_move (enum machine_mode, rtx[]);
 extern void ix86_expand_vector_move_misalign (enum machine_mode, rtx[]);
+extern void ix86_expand_push (enum machine_mode, rtx);
 extern rtx ix86_fixup_binary_operands (enum rtx_code,
 				       enum machine_mode, rtx[]);
 extern void ix86_fixup_binary_operands_no_copy (enum rtx_code,
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.785
diff -u -p -d -r1.785 i386.c
--- config/i386/i386.c	20 Jan 2005 10:15:13 -0000	1.785
+++ config/i386/i386.c	20 Jan 2005 18:18:25 -0000
@@ -7754,6 +7754,24 @@ ix86_expand_vector_move_misalign (enum m
     gcc_unreachable ();
 }
 
+/* Expand a push in MODE.  This is some mode for which we do not support
+   proper push instructions, at least from the registers that we expect
+   the value to live in.  */
+
+void
+ix86_expand_push (enum machine_mode mode, rtx x)
+{
+  rtx tmp;
+
+  tmp = expand_simple_binop (Pmode, PLUS, stack_pointer_rtx,
+			     GEN_INT (-GET_MODE_SIZE (mode)),
+			     stack_pointer_rtx, 1, OPTAB_DIRECT);
+  if (tmp != stack_pointer_rtx)
+    emit_move_insn (stack_pointer_rtx, tmp);
+
+  tmp = gen_rtx_MEM (mode, stack_pointer_rtx);
+  emit_move_insn (tmp, x);
+}
 
 /* Fix up OPERANDS to satisfy ix86_binary_operator_ok.  Return the
    destination to use for the operation.  If different from the true
Index: config/i386/mmx.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/mmx.md,v
retrieving revision 1.4
diff -u -p -d -r1.4 mmx.md
--- config/i386/mmx.md	18 Jan 2005 06:17:55 -0000	1.4
+++ config/i386/mmx.md	20 Jan 2005 18:18:25 -0000
@@ -175,6 +175,14 @@
   [(const_int 0)]
   "ix86_split_long_move (operands); DONE;")
 
+(define_expand "push<mode>1"
+  [(match_operand:MMXMODE 0 "register_operand" "")]
+  "TARGET_SSE"
+{
+  ix86_expand_push (<MODE>mode, operands[0]);
+  DONE;
+})
+
 (define_expand "movmisalign<mode>"
   [(set (match_operand:MMXMODE 0 "nonimmediate_operand" "")
 	(match_operand:MMXMODE 1 "nonimmediate_operand" ""))]
Index: config/i386/sse.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/sse.md,v
retrieving revision 1.5
diff -u -p -d -r1.5 sse.md
--- config/i386/sse.md	18 Jan 2005 03:44:16 -0000	1.5
+++ config/i386/sse.md	20 Jan 2005 18:18:25 -0000
@@ -194,6 +194,14 @@
   operands[2] = CONST0_RTX (DFmode);
 })
 
+(define_expand "push<mode>1"
+  [(match_operand:SSEMODE 0 "register_operand" "")]
+  "TARGET_SSE"
+{
+  ix86_expand_push (<MODE>mode, operands[0]);
+  DONE;
+})
+
 (define_expand "movmisalign<mode>"
   [(set (match_operand:SSEMODE 0 "nonimmediate_operand" "")
 	(match_operand:SSEMODE 1 "nonimmediate_operand" ""))]
Index: testsuite/gcc.c-torture/execute/va-arg-25.x
===================================================================
RCS file: testsuite/gcc.c-torture/execute/va-arg-25.x
diff -N testsuite/gcc.c-torture/execute/va-arg-25.x
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.c-torture/execute/va-arg-25.x	20 Jan 2005 18:18:26 -0000
@@ -0,0 +1,12 @@
+# With -Os we default to -mpreferred-stack-boundary=2, which is not
+# enough for proper operation with V4SImode when the architecture
+# default enables SSE.  Arguably setting -mpreferred-stack-boundary=2
+# under this condition is incorrect.  Finding the correct set of 
+# options such that we don't exchange a FAIL for an XPASS is hard;
+# simply force the stack boundary we need and forget about it for now.
+
+if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
+	set additional_flags "-mpreferred-stack-boundary=4"
+}
+
+return 0


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