News for hackers. Stuff that matters.
Re:Will it optimize? by grogers on Friday July 23, 2010 @02:18PM (#1541968)
"2. Loop-invariant strlen()

GCC does this optimization, because strlen is a "built-in function:" one that gcc recognizes and optimizes specially. Disabling built-ins with -fno-builtin defeats this optimization."

No, it does it because strlen is declared to be a pure function, and it is smart enough to realize you are not modifying anything in s. -fno-builtin does not change the generated code, it still calls the strlen function (at least on my gcc), but it is hoisted out of the loop.

Re:Will it optimize? by astrange on Saturday July 24, 2010 @06:08AM (#1543421)
strlen() is not declared pure in the OS X headers.
Re:Will it optimize? by gfodor on Friday July 23, 2010 @08:27PM (#1542781)
If this is true it makes me happy because this is surely less of a hack.