This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [3.1.1] Re: GCC performance regression - its memset!
- From: Roger Sayle <roger at eyesopen dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Jan Hubicka <jh at suse dot cz>, <gcc-patches at gcc dot gnu dot org>, <gcc at gcc dot gnu dot org>
- Date: Mon, 20 May 2002 12:06:52 -0600 (MDT)
- Subject: Re: [3.1.1] Re: GCC performance regression - its memset!
> Do you consider -O or -O2 a special switch?
> Anyway, could the testcase be commited with the patch too (the bug shows
> up in C too BTW)?
>
> --- gcc/testsuite/gcc.c-torture/execute/20020520-1.c.jj Thu Aug 30 22:30:55 2001
> +++ gcc/testsuite/gcc.c-torture/execute/20020520-1.c Mon May 20 19:00:41 2002
> @@ -0,0 +1,20 @@
> +/* PR optimization/6703 */
> +extern void abort (void);
> +extern void exit (int);
> +
> +void foo (void **x, int y)
> +{
> + __builtin_memset (x, 0, y);
> +}
> +
> +int main ()
> +{
> + unsigned char x[8] __attribute__ ((aligned (4)));
> + int i;
> +
> + __builtin_memset (x, 0x5a, sizeof (x));
> + foo ((void **) (x + 3), 1);
> + for (i = 0; i < 8; i++)
> + if (x[i] != (i != 3 ? 0x5a : 0))
> + abort ();
> + exit (0);
> +}
Hi Jakub,
As I've mentioned in a previous e-mail, I believe that this test
case is poorly formed; quite clearly the x argument to foo is
incorrectly aligned for the type. On many platforms, the above
code (and even with foo defined as "*x = 0;") will fail at runtime.
The benefit of Jan's patch is that on machines without alignment
restrictions, we'll still produce the "expected behaviour" for
incorrectly written programs. Mozilla's source code is incorrect
and needs to be fixed (use void* rather than void**). This isn't
really a correctness PR, more a quality of implementation for
undefined behaviour PR.
Roger
--