https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90373
Bug ID: 90373 Summary: Better alias analysis based on libc functions with arguments which cannot alias Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: david.bolvansky at gmail dot com Target Milestone: --- bool foo(int *a, int *b, unsigned n) { memcpy(a, b, n); return a == b; } GCC trunk X86-64 -O3 foo(int*, int*, unsigned int): push rbx mov edx, edx mov rbx, rsi call memcpy cmp rax, rbx pop rbx sete al ret if a and b aliases, it would be UB to call memcpy since "The memory areas must not overlap.". Currently GCC emits "a == b", but possibly, info that a cannot alias b in range n could be propagated more. Same for strcpy "The strings may not overlap, and the destination string dest must be large enough to receive the copy."