Bug 65197 - static initialization via intel intrinsics
Summary: static initialization via intel intrinsics
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2015-02-24 22:02 UTC by Marc Glisse
Modified: 2016-03-28 00:37 UTC (History)
1 user (show)

See Also:
Target: x86_64-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Marc Glisse 2015-02-24 22:02:41 UTC
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.
Comment 1 Andrew Pinski 2016-01-24 07:34:53 UTC
For C++11/14/17 (17 has more freedoms for constexpr) reasons it might make sense to mark _mm_set_epi64x as constexpr.