[Bug c++/82505] New: g++ -O3 -funroll-loops generates weird code
barto at cambridgesemantics dot com
gcc-bugzilla@gcc.gnu.org
Tue Oct 10 15:09:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82505
Bug ID: 82505
Summary: g++ -O3 -funroll-loops generates weird code
Product: gcc
Version: 7.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barto at cambridgesemantics dot com
Target Milestone: ---
Created attachment 42334
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42334&action=edit
Assembly output from g++ -O3 -funroll-loops -S
In the following code, the first two tests generate much the same code when
compiled
with g++ -O3 -funroll-loops.
The third test generates an excess of loads and moves. Assembly attached.
extern char *dest;
extern char *src;
int t0()
{
for (int i = 0; i < 5; ++i)
{
dest[i] = src[i];
}
}
int t1()
{
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
dest[3] = src[3];
dest[4] = src[4];
}
int t2()
{
for (int i = 0; i < 5; ++i)
{
*dest = *src;
++dest;
++src;
}
}
More information about the Gcc-bugs
mailing list