Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
48 Views

SIMD and constexpr


Hi, I am writing some SIMD code where I would like to initialize a constant at compile-time with constexpr.
Both GCC and Clang are happy with code like shown below, but ICC unfortunately errors out.

using float_v = float __attribute__((vector_size(16)));
constexpr float_v broadcast(float x) return float_v{x, x, x, x}; }
float test() {  float_v v = broadcast(0); return v[0]; }

https://godbolt.org/g/a333Mn

Does anyone know how to make this work on ICC without resorting to intrinsics?
 

0 Kudos
2 Replies
Highlighted
Moderator
48 Views

Hi,

This is a known issue in our Front End. There is an internal bug tracker for it (CMPLRS-7400). We'll keep you updated when the fix is avail.

Thanks,

Viet 

0 Kudos
Highlighted
Beginner
48 Views

Thank you. For now I am using C++14 and initializing the vector with a for loop like this:

#ifdef __INTEL_COMPILER
    static constexpr float_v make_array(const float& val)
    {
      float_v a; 
      for (size_t i = 0; i < N; ++i) 
         a = val; 
      return a;
    }
#else
 // ...
#endif

 

 

0 Kudos