| Issue |
161273
|
| Summary |
[AArch64] Suboptimal lowering for `icmp` on `i128` when RHS is an immediate
|
| Labels |
backend:AArch64,
missed-optimization
|
| Assignees |
|
| Reporter |
Kmeakin
|
https://godbolt.org/z/e3dbGonz7
When both expressions being compared are variables, LLVM generates optimal assembly
But when one of the expressions is an immediate, suboptimal code is generated in some cases:
For `eq` and `ne`:
```asm
eq_imm(unsigned __int128):
mov w8, #5
eor x8, x0, x8
orr x8, x8, x1
cmp x8, #0
cset w0, eq
ret
```
the optimal code would be:
```asm
eq_imm(unsigned __int128):
cmp x0, #5
ccmp x1, #5, #0, eq
cset w0, eq
ret
```
For `ult` and `ule`:
```asm
ugt_imm(unsigned __int128):
mov w8, #5
cmp x8, x0
ngcs xzr, x1
cset w0, lo
ret
```
the optimal code would be:
```asm
ugt_imm(unsigned __int128):
cmp x0, #5
ccmp x1, #0, #0, ls
cset w0, ne
ret
```
For `sgt` and `sle`:
```asm
sgt_imm(__int128):
mov w8, #5
cmp x8, x0
ngcs xzr, x1
cset w0, lt
ret
```
should be:
```asm
sgt_imm(__int128):
cmp x1, #0
ccmp x0, #5, #4, ge
cset w0, gt
ret
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs