https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104579
Bug ID: 104579 Summary: vectorizer failed to reduce max & index search together Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: crazylht at gmail dot com Target Milestone: --- int max (int *src, int n, int *position) { int maxInt; int maxIndex; int i; maxInt = src[0]; maxIndex = 0; for (i = 1; i < n; i++) { if (maxInt < src[i]) { maxInt = src[i]; maxIndex = i; } } *position = maxIndex; return (maxInt); } GCC can reduce max and index search separately, but not together.