[Bug c/80161] New: const argument hidden from AVX intrinsics due to OpenMP outlining
jeff.science at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Mar 23 16:46:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80161
Bug ID: 80161
Summary: const argument hidden from AVX intrinsics due to
OpenMP outlining
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jeff.science at gmail dot com
Target Milestone: ---
I get "error: the last argument must be scale 1, 2, 4, 8" when the argument is
"const int scale = 1", only when OpenMP is active.
Having seen similar issues in other compilers, I suspect that the OpenMP
outlining creates an indirection in which the constant properties of "scale"
are lost and thus not visible to the pass that parses intrinsics.
I know that manually inlining and the preprocessor provide a way to solve this,
but neither of those meets other requirements.
# Source Code
$ cat gccbug.c
#include "emmintrin.h"
#include "immintrin.h"
void copy_vgatherdpd128(size_t n, const double * restrict a, double * restrict
b)
{
__m128i vindex = _mm_set_epi32(-1,-1,8,0);
const int scale = 1;
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (size_t i=0; i<n; i+=2) {
__m128d t = _mm_i32gather_pd( &(a[i]), vindex, scale );
_mm_storel_pd( &(b[i ]), t);
_mm_storeh_pd( &(b[i+1]), t);
}
}
# Build without OpenMP
[jrhammon@esgmonster simd-memtest]$ gcc-7 -O3 -march=core-avx2 -std=gnu11 -g3
-Wall -c gccbug.c -o gccbug.o
# Build with OpenMP
[jrhammon@esgmonster simd-memtest]$ gcc-7 -O3 -march=core-avx2 -std=gnu11 -g3
-Wall -fopenmp -c gccbug.c -o gccbug.o
In file included from
/opt/gcc/HEAD/lib/gcc/x86_64-pc-linux-gnu/7.0.1/include/immintrin.h:43:0,
from gccbug.c:2:
/opt/gcc/HEAD/lib/gcc/x86_64-pc-linux-gnu/7.0.1/include/avx2intrin.h: In
function ‘copy_vgatherdpd128._omp_fn.0’:
/opt/gcc/HEAD/lib/gcc/x86_64-pc-linux-gnu/7.0.1/include/avx2intrin.h:1254:10:
error: the last argument must be scale 1, 2, 4, 8
return (__m128d) __builtin_ia32_gathersiv2df (_mm_undefined_pd (),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__base,
~~~~~~~
(__v4si)__index,
~~~~~~~~~~~~~~~~
__mask,
~~~~~~~
__scale);
~~~~~~~~
# GCC details
I compiled GCC from Git HEAD today.
$ gcc-7 -v
Using built-in specs.
COLLECT_GCC=gcc-7
COLLECT_LTO_WRAPPER=/opt/gcc/HEAD/bin/../libexec/gcc/x86_64-pc-linux-gnu/7.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /opt/gcc//git/configure --program-suffix=-7 --disable-multilib
--enable-threads=posix --enable-checking=release --with-system-zlib
--enable-__cxa_atexit --enable-languages=c,c++,fortran --with-tune=native
--enable-bootstrap --enable-lto --enable-gold=yes --enable-ld=yes
--prefix=/opt/gcc//HEAD
Thread model: posix
gcc version 7.0.1 20170323 (experimental) (GCC)
$ gcc-7 --version
gcc-7 (GCC) 7.0.1 20170323 (experimental)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
More information about the Gcc-bugs
mailing list