GCC should optimize printf("%s",foo) and printf("foo") into fputs(foo,stdout) 
and fputs("foo",stdout) respectively.  As noted here:

http://gcc.gnu.org/ml/gcc-patches/2000-09/msg00859.html

We can capture stdout in an inline function using fixincl, perhaps adding the 
__always_inline__ attribute.  Then do the above transformation.

In at least the printf("%s", foo) case, the result fputs(foo,stdout) has the 
same number of arguments, so it might not even be a -Os problem.

-- 
           Summary: GCC should optimize printf("%s",foo) and printf("foo")
                    into fputs(foo,stdout)
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ghazi at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21988

Reply via email to