http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59071
Bug ID: 59071 Summary: sse2 intrinsics and constant expressions Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vermaelen.wouter at gmail dot com gcc-4.8.2 with -O0 rejects the following code. With -O1 it works fine. Gcc-4.6, 4.7 and clang also work fine. I *believe* the stuff below is a constant expression, so it should compile (even without optimizations enabled). ------- #include "emmintrin.h" template<int N> __m128i foo(__m128i x) { return _mm_slli_si128(x, sizeof(__m128i) - N); } void bar(__m128i x) { foo<4>(x); } -------- > g++ test.cc In file included from test.cc:1:0: test.cc: In function ‘__m128i foo(__m128i) [with int N = 4; __m128i = __vector(2) long long int]’: test.cc:4:9: error: the last argument must be an 8-bit immediate return _mm_slli_si128(x, sizeof(__m128i) - N);