http://bugs.llvm.org/show_bug.cgi?id=32070
Bug ID: 32070
Summary: Special-case memcpy() after conditional block
Product: new-bugs
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedb...@nondot.org
Reporter: simonhosie77+l...@gmail.com
CC: llvm-bugs@lists.llvm.org
Given:
void f(void *d, void const* s, size_t l, int c) {
if (__builtin_expect(c != 0, 1)) {
l = 0;
}
__builtin_memcpy(d, s, l);
}
Compiling this I get a conditional set-register-to-zero and unconditional call
to memcpy().
Ideally we'd just skip over the call when c != 0. Changing the code to this
makes everything better, but it's not automatic, and in realistic code it's not
something I'd want to do manually:
void f(void *d, void const* s, size_t l, int c) {
if (__builtin_expect(c != 0, 1)) {
l = 0;
__builtin_memcpy(d, s, l);
} else {
__builtin_memcpy(d, s, l);
}
}
Generally, finishing a conditional block with additional optimisation
information might produce a candidate for special-case implementation of the
common code that follows it. For __builtin_memcpy() this would include l being
set to any small constant.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs