| Issue |
167385
|
| Summary |
[clang] For loop generates call to `memcmp`, call to `memcmp` generates call to bcmp`
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
davidstone
|
The following code:
```c++
#include <cstring>
constexpr auto size = 16;
struct array {
int m[size];
};
auto equal(
array const lhs,
array const rhs
) -> bool {
#ifdef MANUAL
for (int n = 0; n != size; ++n) {
if (lhs.m[n] != rhs.m[n]) {
return false;
}
}
return true;
#else
return std::memcmp(lhs.m, rhs.m, size * sizeof(int)) == 0;
#endif
}
```
Generates this assembly with `-O3 -DMANUAL`
```asm
equal(array, array):
push rax
lea rdi, [rsp + 16]
lea rsi, [rsp + 80]
mov edx, 64
call memcmp@PLT
test eax, eax
sete al
pop rcx
ret
```
but with just `-O3` it generates
```asm
equal(array, array):
push rax
lea rdi, [rsp + 16]
lea rsi, [rsp + 80]
mov edx, 64
call bcmp@PLT
test eax, eax
sete al
pop rcx
ret
```
See it live: https://godbolt.org/z/xEeGMP153
I would expect both versions to generate the call to `bcmp`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs