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

--- Comment #4 from Evgeniy Dushistov <dushistov at mail dot ru> ---
>Such an optimization can increase code size
>if the same format string is used with 
>many different arguments,

may be then two fputs calls?

fputs(__PRETTY_FUNCTION__, stdout);
fputs("%s: test1\n" + 2/*skip format*/, stdout);

yeah, still we have two calls vs one(bad for -Os),
but we not introduce new string constants,
so it is suitable optimization for -Ofast.

In such test:
       for (int i = 0; i < 100000; ++i) {
        #ifdef OPTIMIZATION
                fputs(__PRETTY_FUNCTION__, stdout);
                fputs("%s: test1\n" + 2, stdout);
        #else
                printf("%s: test1\n", __PRETTY_FUNCTION__);
        #endif
        }

fputs win with 
real    0m0.005s
user    0m0.000s
sys     0m0.000s

vs printf
real    0m0.011s
user    0m0.010s
sys     0m0.000s

Reply via email to