https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91096
Bug ID: 91096 Summary: Openmp vector max reduction incorrect Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: wilco at gcc dot gnu.org Target Milestone: --- The new gcc.dg/vect/vect-simd-14.c test produces incorrect reduction due to the vectorizer adding fmax (result, FLT_MAX): float b[1024], a[1024]; __attribute__((noipa)) float bar (void) { float s = -__builtin_inff (); #pragma omp simd reduction (inscan, max:s) for (int i = 0; i < 1024; i++) { b[i] = s; #pragma omp scan exclusive(s) s = s > a[i] ? s : a[i]; } return s; } When built with -ffast-math -ftree-vectorize -O2 -fdump-tree-vect-details -fopenmp-simd it shows the following constants being used in the fmax operations: vect_cst__30 = { -3.4028234663852885981170418348451692544e+38, -3.4028234663852885981170418348451692544e+38, -3.4028234663852885981170418348451692544e+38, -3.4028234663852885981170418348451692544e+38 }; This is 0xff7fffff / -0x1.fffffep+127 / FLT_MAX. As a result b[0] has the wrong value - it should be -inff.