https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98927
Bug ID: 98927
Summary: Code using _mm_extract_epi16 compiles with -O3 but not
on other optimization modes
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
#include <stdint.h>
#include <x86intrin.h>
void f(int16_t *out, __m128i packed)
{
for (unsigned i = 0; i < 8; i++)
out[i] = _mm_extract_epi16(packed, i);
}
This compiles with -O3, but fails on -O2 and below with this message:
In file included from
/opt/compiler-explorer/gcc-trunk-20210202/lib/gcc/x86_64-linux-gnu/11.0.0/include/xmmintrin.h:1316,
from
/opt/compiler-explorer/gcc-trunk-20210202/lib/gcc/x86_64-linux-gnu/11.0.0/include/immintrin.h:31,
from
/opt/compiler-explorer/gcc-trunk-20210202/lib/gcc/x86_64-linux-gnu/11.0.0/include/x86intrin.h:32,
from <source>:2:
/opt/compiler-explorer/gcc-trunk-20210202/lib/gcc/x86_64-linux-gnu/11.0.0/include/emmintrin.h:
In function 'void f(int16_t*, __m128i)':
/opt/compiler-explorer/gcc-trunk-20210202/lib/gcc/x86_64-linux-gnu/11.0.0/include/emmintrin.h:1391:55:
error: selector must be an integer constant in the range [0, 7]
1391 | return (unsigned short) __builtin_ia32_vec_ext_v8hi ((__v8hi)__A,
__N);
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
Compiler returned: 1
Is this intended behaviour ? It seems odd to make it valid to have code rely on
loop unrolling for it to compile at all.