Issue |
123239
|
Summary |
Unnecessarily large constant created from reordering add and shift
|
Labels |
new issue
|
Assignees |
|
Reporter |
dzaima
|
https://godbolt.org/z/xoKf6bnTb
The code:
```c
#include<stdint.h>
#include<stdbool.h>
bool foo(uint64_t x) {
uint16_t tag = x>>48;
return tag>=0b1111111111110010 && tag<=0b1111111111110100;
}
```
with `-O3` as of clang 19 (and still in trunk) compiles to:
```asm
foo:
movabs rax, 3940649673949184
add rax, rdi
shr rax, 48
cmp eax, 3
setb al
ret
```
whereas 18.0 did this, which is strictly better (i.e. is the exact same set of instructions, just in a different order and without movabs):
```asm
foo:
shr rdi, 48
add edi, -65522
cmp edi, 3
setb al
ret
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs