| Issue |
75455
|
| Summary |
Missed optimization: not tail calling memset
|
| Labels |
llvm:optimizations,
missed-optimization
|
| Assignees |
|
| Reporter |
dvyukov
|
The code is (extracted from calloc implementation):
```
void* foo(void* x, long s) {
if (__builtin_expect(x != nullptr, true))
return __builtin_memset(x, 0, s);
return x;
}
```
Clang generages:
```
foo(void*, long): # @foo(void*, long)
pushq %rbx
movq %rdi, %rbx
testq %rdi, %rdi
je .LBB0_2
movq %rsi, %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq memset@PLT
.LBB0_2:
movq %rbx, %rax
popq %rbx
retq
```
https://godbolt.org/z/YojTG44bs
This should be:
```
foo(void*, long): # @foo(void*, long)
testq %rdi, %rdi
je .LBB0_2
movq %rsi, %rdx
xorl %esi, %esi
jmp memset@PLT
.LBB0_2:
retq
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs