[Bug middle-end/84083] [missed optimization] loop-invariant strlen() not hoisted out of loop
eyalroz at technion dot ac.il
gcc-bugzilla@gcc.gnu.org
Mon Jan 29 13:17:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84083
--- Comment #4 from Eyal Rozenberg <eyalroz at technion dot ac.il> ---
(In reply to Richard Biener from comment #3)
> Yes, we don't currently implement restrict disambiguation for calls.
So, would that account for the different compilation result for test1() and
test2() in the following code:
#include <string.h>
inline size_t my_strlen(const char* __restrict__ s)
{
const char* p = s;
while(*p != '\0') { p++; }
return p - s;
}
size_t test1()
{
static const char* hw = "Hello, world!";
return my_strlen(hw);
}
size_t test2()
{
static const char* hw = "Hello, world!";
return strlen(hw);
}
where test2() compiles to just returning a fixed value while test1() executes a
loop (See https://godbolt.org/g/CvVxru) ?
More information about the Gcc-bugs
mailing list