[Bug c/91526] Unnecessary SSE and other instructions generated when compiling in C mode (vs. C++ mode)
bisqwit at iki dot fi
gcc-bugzilla@gcc.gnu.org
Fri Aug 23 08:03:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91526
Joel Yliluoma <bisqwit at iki dot fi> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bisqwit at iki dot fi
--- Comment #2 from Joel Yliluoma <bisqwit at iki dot fi> ---
The theory that it is related to RVO seems to be confirmed by the fact that if
the code is changed like this:
struct Vec { float v[8]; };
void multiply(struct Vec* result,
const struct Vec* __restrict__ v1,
const struct Vec* __restrict__ v2)
{
for(unsigned i = 0; i < 8; ++i)
result->v[i] = v1->v[i] * v2->v[i];
}
Then it gets compiled in the shorter and proper form. Interestingly, even if
the __restrict__ attribute is removed, it still gets vectorized. Is this
correct behavior?
More information about the Gcc-bugs
mailing list