Skip to content

Compiler bugs

Naoki Shibata edited this page Feb 22, 2021 · 2 revisions

These are part of compiler bugs I found.

// clang-9 -O -mavx512f clang9bug.c -S

#include <x86intrin.h>

typedef struct { __m512i x, y; } vmask2;

static __m512i vcast_vm_i_i(int i0, int i1) {
  return _mm512_set_epi32(i0, i1, i0, i1, i0, i1, i0, i1, i0, i1, i0, i1, i0, i1, i0, i1);
}

__mmask16 bug(vmask2 a, vmask2 b) {
  b.x = _mm512_add_epi64(_mm512_xor_si512(b.x, vcast_vm_i_i(0xffffffff, 0xffffffff)), vcast_vm_i_i(0, 1));
  b.y = _mm512_add_epi64(b.y, _mm512_mask_and_epi64(_mm512_set1_epi32(0), _mm512_cmp_epi64_mask(b.x, vcast_vm_i_i(0, 0), _MM_CMPINT_EQ), vcast_vm_i_i(0, 1), vcast_vm_i_i(0, 1)));
  return _mm512_kand(_mm512_cmp_epi64_mask(b.y, a.y, _MM_CMPINT_EQ), _mm512_cmp_epi64_mask(b.x, a.x, _MM_CMPINT_EQ));
}
  • The following source code generates an internal compiler error with gcc-4.8. This is fixed in gcc-5, and not reported.
typedef long double vlongdouble __attribute__((vector_size(sizeof(long double)*2)));
vlongdouble vcast_vl_l(long double d) { return (vlongdouble) { d, d }; }

int main() {
  vlongdouble vld = vcast_vl_l(0);
}
Clone this wiki locally