Issue |
134474
|
Summary |
[X86] `and`/`or` could use 8-bit immediate for more constant arguments
|
Labels |
new issue
|
Assignees |
|
Reporter |
dzaima
|
The functions:
```c
void f1(long* dst, long x) {
*dst = x | 200;
}
void f2(long* dst, long x) {
*dst = x & -200;
}
```
for x86-64 with `-O3` (or even `-Oz`) compile to:
```asm
or rsi, 0xc8 ; 48 81 ce c8 00 00 00
and rsi, 0xffffffffffffff38 ; 48 81 e6 38 ff ff ff
```
whereas they could be:
```asm
or sil, 0xc8 ; 40 80 ce c8
and sil, 0x38 ; 40 80 e6 38
```
This applies to `|` for immediate arguments of 128..255, and for `&` with -256..-129. (`x & -256` can furthermore be `xor sil,sil`)
([uops.info](https://uops.info/table.html?search=and%20r%20i%208&cb_lat=on&cb_tp=on&cb_ports=on&cb_CON=on&cb_NHM=on&cb_SNB=on&cb_HSW=on&cb_SKX=on&cb_TGL=on&cb_ADLP=on&cb_BNL=on&cb_GLP=on&cb_ADLE=on&cb_ZENp=on&cb_ZEN2=on&cb_ZEN3=on&cb_ZEN4=on&cb_measurements=on&cb_base=on) says that the `(R8l, I8)` and `(R64, I32)` variants in question are largely equivalent)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs