This is the mail archive of the 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: [3.1.1] Re: GCC performance regression - its memset!

> 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


FWIW, I think this really is a regression...  The problem is really
that memset doesn't properly set bytes at the tail of the buffer.
How about this testcase?

- Glen Nakamura

/* PR optimization/6703 */
extern void abort (void);
extern void exit (int);

void foo (int *x, int y)
  __builtin_memset (x, 0, y);

int main ()
  int x[2] = { 0x5a5a5a5a, 0x5a5a5a5a };

  if (x[1] != 0x5a5a5a5a)
      abort ();
  foo (x, 5);
  if (x[1] == 0x5a5a5a5a)
      abort ();
  exit (0);

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