| Issue |
71306
|
| Summary |
Missed optimization: add+add instead of lea
|
| Labels |
backend:X86
|
| Assignees |
|
| Reporter |
dvyukov
|
The code is:
```
void* alloc(long* base, long cl) {
long header = base[cl];
const long ptr_mask = ((1l << 56) - 1);
if ((header & ptr_mask) == 0)
return slowmalloc();
void* ptr = (void*)(header & ptr_mask);
void* next = *(void**)ptr;
base[cl] = (long)next | (header & ~ptr_mask) + (1l << 56);
return ptr;
}
```
clang 17.0.1 produces the following x86 code:
```
movabs $0xffffffffffffff,%rcx
...
add %rdx,%rcx
inc %rcx
```
The add+inc sequence could be `lea 1(%rdx, %rcx), %rcx`, which is 1 instruction and 1 byte less.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs