On Wed, Feb 23, 2000 at 11:04:35AM +0100, Erwin Authried wrote:
> David Schleef[SMTP:[EMAIL PROTECTED]] wrote:
> > 
> > Nope.  gcc-2.7.2.3 outputs assembly instructions that perform
> > the memcpy, even with very long strings.
> > 
> > 
> > 
> > dave...
> > 
> Be careful. With *exactly* the statement above, compiled with -O2,  memset is called.
> With some shorter or longer strings, memset is not used. 
> 
> -erwin
>  


You are correct.  I somehow managed to completely ignore "memset" and
focused instead on my incorrect interpretation of "memset" as "memcpy".

I'm happy you corrected me, because this brings up gcc bugs/features
(depending on perspective) on multiple levels.

On one level, gcc optimization is _definiately_ wrong calling
memset(ptr,0,3) instead of the trivial two or three instructions
required to zero by hand.  This appears to be the behavior in both
gcc-2.7.2.3 and egcs-2.91.66.  This deserves a bug report.

Then, of course, it is not clear that gcc should be calling library
functions instead of __builtin_memset or just inlining memset code,
especially when the -fno-builtins flag is set.  It is true that
memset can have no other legitimate meaning.  But clearly, for the
purposes here, generating "call memset" is not useful, and in other
circumstances, "call memset" is definately bad.

Grepping the gcc source indicates that there are a number of function
calls that gcc will emit in certain circumstances.




dave...


-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/

Reply via email to