[llvm-bugs] [Bug 47153] New: Failure to optimize out strlen that isn't used for any other purpose than more strlen calls (which don't have any external effect)

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 13 00:42:50 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47153

            Bug ID: 47153
           Summary: Failure to optimize out strlen that isn't used for any
                    other purpose than more strlen calls (which don't have
                    any external effect)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: gabravier at gmail.com
                CC: llvm-bugs at lists.llvm.org

void f(const char *a)
{
    while (*a)
        a += strlen(a);
}

This can be optimized to doing nothing. This transformation is done by GCC, but
not by LLVM. The same transformation can be done if `strlen(a)` is replaced by
`strspn(a, some_other_string)`, and can probably also be done for more examples
alike to this with alike functions.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200813/1ff16122/attachment.html>


More information about the llvm-bugs mailing list