https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121631
Bug ID: 121631 Summary: Signed overflow introduced by vectorizer Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: kristerw at gcc dot gnu.org Target Milestone: --- PR111494 did not fix all cases where the vectorizer introduces new signed overflow when calculating a sum. One example that still fails is the function below, when compiled for x86_64 with -O3. The final reduction in the vectorized code is performed using signed integer scalar addition: _16 = BIT_FIELD_REF <vect_sum2_14.12_17, 32, 0>; _9 = BIT_FIELD_REF <vect_sum2_14.12_17, 32, 32>; _8 = BIT_FIELD_REF <vect_sum2_14.12_17, 32, 64>; _7 = BIT_FIELD_REF <vect_sum2_14.12_17, 32, 96>; _37 = _16 + _8; _38 = _9 + _7; res1 = _37; res2 = _38; struct mystr { int f1; int f2; }; struct mystr a[16]; struct mystr b[16]; int res1, res2; void foo (void) { int i; int sum1 = 0; int sum2 = 0; for (i = 0; i < 16; i++) { sum1 += a[i].f1 + b[i].f1; sum2 += a[i].f2 + b[i].f2; } res1 = sum1; res2 = sum2; }