[WIP PATCH] Fix i?86/x86_64 setmem/movmem expansion (PR target/38708)

Jakub Jelinek jakub@redhat.com
Sat Jan 3 19:40:00 GMT 2009


Hi!

This patch cures a bunch of testsuite failures with
--target_board=unix/-m32/-mtune=pentium-m:

-FAIL: gcc.c-torture/execute/memset-3.c execution,  -O1 
-FAIL: gcc.c-torture/execute/memset-3.c execution,  -O2 
-FAIL: gcc.c-torture/execute/memset-3.c execution,  -O3 -fomit-frame-pointer 
-FAIL: gcc.c-torture/execute/memset-3.c execution,  -O3 -fomit-frame-pointer -funroll-loops 
-FAIL: gcc.c-torture/execute/memset-3.c execution,  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions 
-FAIL: gcc.c-torture/execute/memset-3.c execution,  -O3 -g 
-FAIL: tmpdir-gcc.dg-struct-layout-1/t027 c_compat_x_tst.o-c_compat_y_tst.o execute
-FAIL: tmpdir-gcc.dg-struct-layout-1/t028 c_compat_x_tst.o-c_compat_y_tst.o execute
-FAIL: gcc.dg/20020525-1.c execution test
-FAIL: tmpdir-g++.dg-struct-layout-1/t028 cp_compat_x_tst.o-cp_compat_y_tst.o execute
-FAIL: libgomp.c/pr26943-2.c execution test
-FAIL: libgomp.c/pr26943-3.c execution test

Unfortunately:

 FAIL: gcc.c-torture/execute/memset-2.c execution,  -O3 -fomit-frame-pointer 
 FAIL: gcc.c-torture/execute/memset-2.c execution,  -O3 -fomit-frame-pointer -funroll-loops 
 FAIL: gcc.c-torture/execute/memset-2.c execution,  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions 
 FAIL: gcc.c-torture/execute/memset-2.c execution,  -O3 -g 

keeps failing before and after the patch, so there is probably some other bug
lurking, either in the memset expansion or elsewhere in RTL optimizers.

2009-01-03  Jakub Jelinek  <jakub@redhat.com>

	PR target/38708
	* config/i386/i386.c (override_options): Reject
	-mstringop-strategy=rep_8byte with -m32.
	(ix86_expand_movmem): For size_needed == 1 set epilogue_size_needed
	to 1.
	(ix86_expand_setmem): Likewise.  Compare size_needed with
	epilogue_size_needed instead of desired_align - align, don't adjust
	size_needed, pass epilogue_size_needed to the epilogue expanders.

--- gcc/config/i386/i386.c.jj	2008-12-27 10:12:25.000000000 +0100
+++ gcc/config/i386/i386.c	2009-01-03 17:37:06.000000000 +0100
@@ -1,6 +1,6 @@
 /* Subroutines used for code generation on IA-32.
    Copyright (C) 1988, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2006, 2007, 2008
+   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -2686,7 +2686,8 @@ override_options (bool main_args_p)
 	stringop_alg = libcall;
       else if (!strcmp (ix86_stringop_string, "rep_4byte"))
 	stringop_alg = rep_prefix_4_byte;
-      else if (!strcmp (ix86_stringop_string, "rep_8byte"))
+      else if (!strcmp (ix86_stringop_string, "rep_8byte")
+	       && TARGET_64BIT)
 	stringop_alg = rep_prefix_8_byte;
       else if (!strcmp (ix86_stringop_string, "byte_loop"))
 	stringop_alg = loop_1_byte;
@@ -17593,6 +17594,7 @@ ix86_expand_movmem (rtx dst, rtx src, rt
       emit_label (label);
       LABEL_NUSES (label) = 1;
       label = NULL;
+      epilogue_size_needed = 1;
     }
 
   /* Step 3: Main loop.  */
@@ -17962,6 +17964,7 @@ ix86_expand_setmem (rtx dst, rtx count_e
       emit_label (label);
       LABEL_NUSES (label) = 1;
       label = NULL;
+      epilogue_size_needed = 1;
     }
 
   /* Step 3: Main loop.  */
@@ -18012,13 +18015,12 @@ ix86_expand_setmem (rtx dst, rtx count_e
 	 Epilogue code will actually copy COUNT_EXP & EPILOGUE_SIZE_NEEDED
 	 bytes. Compensate if needed.  */
 
-      if (size_needed < desired_align - align)
+      if (size_needed < epilogue_size_needed)
 	{
 	  tmp =
 	    expand_simple_binop (counter_mode (count_exp), AND, count_exp,
 				 GEN_INT (size_needed - 1), count_exp, 1,
 				 OPTAB_DIRECT);
-	  size_needed = desired_align - align + 1;
 	  if (tmp != count_exp)
 	    emit_move_insn (count_exp, tmp);
 	}
@@ -18029,10 +18031,10 @@ ix86_expand_setmem (rtx dst, rtx count_e
     {
       if (force_loopy_epilogue)
 	expand_setmem_epilogue_via_loop (dst, destreg, val_exp, count_exp,
-					 size_needed);
+					 epilogue_size_needed);
       else
 	expand_setmem_epilogue (dst, destreg, promoted_val, count_exp,
-				size_needed);
+				epilogue_size_needed);
     }
   if (jump_around_label)
     emit_label (jump_around_label);


	Jakub



More information about the Gcc-patches mailing list