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]
Other format: [Raw text]

Re: malloc attributes and realloc


On Friday, January 2 2004, "Zack Weinberg" wrote to "Jonathan Lennox, Joseph S. Myers, Daniel Berlin, Ian Lance Taylor, Robert Dewar, gcc@gcc.gnu.org, drow@mvista.com, Gabriel Dos Reis" saying:

> > I.e., if char *p was returned by an attribute(malloc) function, then
> >   if (*p != 'a')
> >     *p = 'a';
> >
> > can be safely optimized into
> >   *p = 'a';
> 
> ... that is *not* an optimization; the cache behavior of the latter is
> likely to be worse than the former.

I was referencing the behavior of if-conversion which Roger Sayle described
in <http://gcc.gnu.org/ml/gcc-patches/2003-12/msg01271.html>.  As I
mentioned, the code's in GCC already.

I don't know much about the logic of if-conversion, but presumably GCC only
does this transformation if it's a general win?

-- 
Jonathan Lennox
lennox at cs dot columbia dot edu


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