This is the mail archive of the gcc@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]

egcs 1.1b: problem when optimizing memset -> bzero


egcs 1.1b, cross-compile for m68k-unknown-ecoff:

I am compiling with -mshort, so ints are 16 bits, but size_t is 32 bits. Now
when compiling the following sample:

#include <string.h> 

size_t a;
int b;
char c[100];

void test(void)
{
  b = sizeof(a);
  memset(c, 0, sizeof(c));
  memset(c, 1, sizeof(c));
}

gcc modifies the first memset and uses a bzero instead - HOWEVER: the
size argument is converted to int instead of size_t, which yields something
like this:

	move.w #100,-(%sp)   ; note the .w here!
	pea _c
	jsr _bzero

instead of the correct

	pea 100.w            ; size_t is 32 bits!
	pea _c
	jsr _bzero


bzero.c is compiled with the same options and expects the size argument to
be size_t (32 bits), but only gets 16 bits on the stack - shrooms!

The 2nd memset (with fill value 1) works as expected, and C-calls to bzero
work fine, too - only when gcc does the conversion from memset to bzero
there is trouble.

I fixed this temporarily by defining TARGET_MEM_FUNCTIONS and recompiling
gcc (btw: in which file in config/m68k/* should this be put?), but a working
conversion to bzero would be better.

cu
Michael
-- 
In the beginning there was nothing, which exploded.


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