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

            Bug ID: 116126
           Summary: vectorize libcpp search_line_fast
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andi-gcc at firstfloor dot org
  Target Milestone: ---

This is somewhat of a metabug to track vectorization of libcpp/lex.c
search_line_fast, which currently has manual vectorization for various
architectures. It would be better if gcc could just figure it out by itself.

The definition is:

// Find any occurrence for \n \r \\ ? and return pointer to it. 
// Can assume that the string ends with \n, so end can be ignored

const unsigned char *search_line_fast (const unsigned char *s, const unsigned
char *end)
{
        for (;;) {
                if (*s == '\n' || *s == '\r' || *s == '\\' || *s == '?')
                        return s;
                s++;
        }
}

currently this fails due to

- Vectorizer cannot determine number of iterations
- Early return is not supported
- if to switch creates an unsupported switch

If we don't ignore end to work around the uncountable problem we get:

const unsigned char *search_line_fast2 (const unsigned char *s, const unsigned
char *end)
{
        while (s < end) {
                if (*s == '\n' || *s == '\r' || *s == '\\' || *s == '?')
                        return s;
                s++;
        }
}

Reply via email to