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

            Bug ID: 96601
           Summary: Failure to optimize equality comparison involving
                    strstr to strlen+strncmp
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

bool f(const char *a, const char *b)
{
    return strstr(a, b) == a;
}

This can be optimized to `strncmp(a, b, strlen(b))`. This transformation is
done by LLVM, but not by GCC.

Reply via email to