I am compiling the following with: g++ -std=gnu++11 -Ofast #include <x86intrin.h> extern const __m128i x = { -1, 0 }; extern const __m128i y = _mm_set_epi64x (0, -1); While x becomes a nice constant in .rodata, y is initialized by _GLOBAL__sub_I_x (copying a constant that is in .rodata). For this specific case, marking _mm_set_epi64x as constexpr gives y the same treatment as x, and I believe we should do that, i.e. mark all intrinsics that can be constexpr in C++11/C++14. However, I believe we are missing an optimization in the general case that would notice (late, after many optimizations) when the initialization function has become unnecessary. Some possibly related bugs: PR4131, PR18399, PR24928, PR37949.
For C++11/14/17 (17 has more freedoms for constexpr) reasons it might make sense to mark _mm_set_epi64x as constexpr.
This is a dup of PR 24928. During the IPA passes we have already: void _GLOBAL__sub_I_x () { <bb 2> [local count: 1073741824]: y = { -1, 0 }; return; } *** This bug has been marked as a duplicate of bug 24928 ***
Sorry I meant PR 4131. *** This bug has been marked as a duplicate of bug 4131 ***