[Bug tree-optimization/58005] missed optimization printf constant string
dushistov at mail dot ru
gcc-bugzilla@gcc.gnu.org
Sat Jul 27 21:02:00 GMT 2013
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
More information about the Gcc-bugs
mailing list