This is the mail archive of the gcc-patches@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: [RFC Patch]: Implement remainder() as built-in function [PR fortran/24518]


On Wed, 25 Oct 2006, Richard Guenther wrote:

> On 10/25/06, Roger Sayle <roger@eyesopen.com> wrote:
> >
> > One obvious use of this scheme would be:
> >
> > #include <stdio.h>
> > FILE *__get_stdout() { return stdout; }
> >
> > The middle-end currently has no-way of manipulating the standard
> > streams "stdin", "stdout" and "stderr".  This is particularly
> > difficult as "stdout" is #defined as iobuf[0] on some platforms,
> > and as _impure_ptr->_stdout on others, etc...
> >
> > Because of this, the middle-end can't transform printf("hello")
> > into fputs("hello",stdout), even though it can currently transform
> > printf("hello\n") into puts("hello"), and can even simplify
> > fprintf(fp,"hello") into fwrite("hello", 1, 5, fp).  Notice,
> > the first requires us to materialize stdout, whereas the latter
> > two don't.
> >
> > It's a very cool solution.  I'm impressed.
>
> I like it as well.  The only concern one could have is that we tie
> libgcc to the libc version used at gcc build time.
>
> But it's only worth it to implement a -fstrict-math-errno to set errno
> even in the cases the system libm doesn't.  Otherwise trading one
> function call for another is not worth the hassle?
> Richard.

I agree with Richard that transforming printf("hello") into
fputs("hello",__get_stdout()) may not be a good option.  It may not
actually be faster if we're calling two functions instead of one.  And it
couldy be a worse code bloating than just adding one extra argument would
normally cause.

Now if you could get it to inline __get_stdout() I would be much more
excited.  See PR21988 and PR24729.  The problem is that ever since we
deleted the RTL inliner, inlining happens to early for us to insert an
inline function during folding and have it get expanded to the body.

		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu


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