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] Fix a bunch of i?86 memcpy/memset expansion bugs (PR target/38686, PR target/38708)


On Fri, Jan 09, 2009 at 05:52:05PM +0100, Jan Hubicka wrote:
> The patch is OK, thanks fo all the work!  (it took me a while to verify
> it but I don't see any problems with changes)

Actually, I found one.  I couldn't reproduce it, because for -O2 small sizes
are cleared or moved by pieces and for -Os desired_align is 1, but
after disabling clear_by_pieces in clear_storage_hints I could reproduce it
with __builtin_memset (buf + 1, 0, 9) for __attribute__((aligned)) buf.
When align_bytes != 0, we subtract the (known) amount of padding inserted
in prologue from count, and if that is smaller than size_needed, zero check
is needed for algorithms that need_zero_guard.  Without this with disabled
clear_by_pieces it stored 17 bytes instead of 9.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed as obvious.

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

	* config/i386/i386.c (ix86_expand_movmem, ix86_expand_setmem): Add
	zero guard even if align_bytes != 0 and count is smaller than
	size_needed.

--- gcc/config/i386/i386.c.jj	2009-01-09 18:10:43.000000000 +0100
+++ gcc/config/i386/i386.c	2009-01-09 19:17:53.000000000 +0100
@@ -17720,7 +17720,7 @@ ix86_expand_movmem (rtx dst, rtx src, rt
 	  count -= align_bytes;
 	}
       if (need_zero_guard
-	  && (!count
+	  && (count < (unsigned HOST_WIDE_INT) size_needed
 	      || (align_bytes == 0
 		  && count < ((unsigned HOST_WIDE_INT) size_needed
 			      + desired_align - align))))
@@ -18112,7 +18112,7 @@ ix86_expand_setmem (rtx dst, rtx count_e
 	  count -= align_bytes;
 	}
       if (need_zero_guard
-	  && (!count
+	  && (count < (unsigned HOST_WIDE_INT) size_needed
 	      || (align_bytes == 0
 		  && count < ((unsigned HOST_WIDE_INT) size_needed
 			      + desired_align - align))))

	Jakub


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