On Godbolt, this executes fine:
volatile __m512i v = _mm512_set_epi64(1, 0, 0, 0, 0, 0, 0, 0);
but all zeros does not:
volatile __m512i v = _mm512_set_epi64(0, 0, 0, 0, 0, 0, 0, 0);
It produces signal SIGILL. Illegal instruction?
Why is this?
I'm using clang 18.1 with flags -std=c++23 -O0 -mavx512vl.
In fact, if I change optimization level, the effect seems to invert. So i'd just like to know why setting different inputs can caused these issues?
You got an AWS instance that doesn't support AVX-512.
You sometimes get Zen 3 (-march=znver3
).
It varies from run to run and I don't know of any way to request a specific instance type. You can use -march=native
and #ifdef __AVX512F__
so your test gets omitted if not supported.
The instance types I remember seeing in the past are Cascade Lake, Ice Lake, and Zen 3. There might now be newer Intel and maybe newer AMD in the mix.
Neither of those vector constants needs a 512-bit instruction to materialize in a register (but might anyway with optimization disabled). But both will use a single 512-bit store to init the volatile
so both versions should make asm that uses an AVX-512 instruction. As you can see from the asm on Godbolt using a ZMM register.