[llvm-bugs] [Bug 47154] New: Failure to optimize strncpy to memcpy

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 13 01:39:32 PDT 2020


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

            Bug ID: 47154
           Summary: Failure to optimize strncpy to memcpy
           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(char *a)
{
    strncpy(a, "dp", 4);
}

This can be optimized to `memcpy(a, "dp\0\0", 4)` (and then most likely the
memcpy call can be inlined). This transformation is done by GCC, but not by
LLVM.

-- 
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/e17785be/attachment.html>


More information about the llvm-bugs mailing list