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

            Bug ID: 91246
           Summary: vectorization failure for a small loop to search array
                    element
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jiangning.liu at amperecomputing dot com
  Target Milestone: ---

For the following simple case, the inner loop can be completely removed by
vectorization. GCC fails to do that. SIZE can be either 4 or 8.

#define SIZE 4
int f(int *data, int x)
{
        int i, j;
        int s = 0;

        for (i = 0; i < 1024; i++) {
                int found = 0;
                for (j = 0; j < SIZE; j++) {
                        if (data[j] == x) {
                                found = 1;
                                break;
                        }
                }
                s += found;
        }

        return s;
}

Reply via email to