Hi,
below you find a small piece of code (which comes from code related to the well Cholesky decomposition, here a matrix with two 6x6 blocks on the diagonal).
- icc 13.x produces correct code with -O2 and -O3
- icc 14 produces correct code with -O2, but wrong code with -O3
- this was tested on two independent icc 14 installations, so it does not seem to be cause by our particular installation
When the "buggy" binary is run, the output varies from run to run (the output vector after the matrix-vector multiplication differs).
Cheers,
Simon
#include <stdlib.h> #include <stdio.h> #include <complex.h> // this multiplies a vector with LL^H, where L is a column-major upper-triangular matrix, // which frequently arises when using Cholesky decompositions void buggy_LLH_multiply(float complex *y, float complex *x, float complex *L) { int i, j; int n; float complex z[6]; for( n=0; n<2; n++) { // z = L^H x for(j=0; j<6; j++) { // columns for(i=0; i<j; i++) { // rows z[i] += conjf(*L)*x[j]; L++; } z[j] = conjf(*L)*x[j]; L++; } L-=21; // y = L*z; for(i=0; i<6; i++) { // rows y[i] = *L * z[0]; L++; for (j=1; j<=i; j++) { // columns y[i] += *L * z[j]; L++; } } x+=6; y+=6; } } int main() { float complex matrix[42]; float complex input_vector[12]; float complex output_vector[12]; int i; for(i=0; i<42; i++) matrix[i] = i; for(i=0; i<12; i++) input_vector[i] = i; buggy_LLH_multiply(output_vector, input_vector, matrix); for(i=0; i<12; i++) printf("%2d % e % e\n", i, creal(input_vector[i]), creal(output_vector[i])); return 0; }