https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112961

            Bug ID: 112961
           Summary: middle-end Missed vectorization: failed to vectorize
                    simple reduction max since GCC-13
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: juzhe.zhong at rivai dot ai
  Target Milestone: ---

#include <algorithm>

int foo(int *a, int n) {
  int max = -987654321;
  for (int i = 0; i < n; ++i)
    max = std::max(max, a[i]);

  return max;
}

This is a simple loop reduction max.

Reference: https://godbolt.org/z/WMvfobK4b

>From the reference, we can know GCC-12 can vectorize it but failed to vectorize
it on both GCC-13 and GCC-14.

Reply via email to