This code:
#include <complex.h>
complex double f(complex double x, complex double y) {
return x*y;
}
when compiled with -O3 -march=core-avx2 -fp-model strict using Intel Compiler version 17 gives
f:
vunpcklpd xmm5, xmm0, xmm1
vmovddup xmm4, xmm2
vmovddup xmm6, xmm3
vshufpd xmm7, xmm5, xmm5, 1
vmulpd xmm8, xmm4, xmm5
vmulpd xmm9, xmm6, xmm7
vaddsubpd xmm0, xmm8, xmm9
vunpckhpd xmm1, xmm0, xmm0
ret
According to Annex G, Section 5.1, Paragraph 4 of the specs:
if x = a * ib is infinite and y = c * id is infinite, the number x * y must be infinite.
But if we let x = inf + i inf (an infinite value) and y = i inf (an infinite value) the result for the Intel code is x * y = NaN + iNaN due to the inf times 0 intermediates. This does not conform to the C99 specs as far as I can see.
Is this a bug and/or is there another set of flags to make complex multiplication C99 compliant?