about summary refs log tree commit diff
path: root/src/test/debuginfo/enum-thinlto.rs
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-11 10:10:41 +0100
committerGitHub <noreply@github.com>2019-12-11 10:10:41 +0100
commit830b4ee76adea7577615c7a6950e14c22cf0fb20 (patch)
treeb2c6c494190484a96c79a0ad042e0a76ea4f7e8f /src/test/debuginfo/enum-thinlto.rs
parentddca1e09c36a6ce21d95fec1619f23ba59b69c8a (diff)
parent1f07aa582a41e6fc253139909d3bf9bfd04a9d6d (diff)
downloadrust-830b4ee76adea7577615c7a6950e14c22cf0fb20.tar.gz
rust-830b4ee76adea7577615c7a6950e14c22cf0fb20.zip
Rollup merge of #66881 - krishna-veerareddy:issue-66780-bool-ord-optimization, r=sfackler
Optimize Ord trait implementation for bool

Casting the booleans to `i8`s and converting their difference into `Ordering` generates better assembly than casting them to `u8`s and comparing them.

Fixes #66780

#### Comparison([Godbolt link](https://rust.godbolt.org/z/PjBpvF))

##### Old assembly:
```asm
example::boolean_cmp:
        mov     ecx, edi
        xor     ecx, esi
        test    esi, esi
        mov     eax, 255
        cmove   eax, ecx
        test    edi, edi
        cmovne  eax, ecx
        ret
```

##### New assembly:
```asm
example::boolean_cmp:
        mov     eax, edi
        sub     al, sil
        ret
```

##### Old LLVM-MCA statistics:
```
Iterations:        100
Instructions:      800
Total Cycles:      234
Total uOps:        1000

Dispatch Width:    6
uOps Per Cycle:    4.27
IPC:               3.42
Block RThroughput: 1.7
```

##### New LLVM-MCA statistics:
```
Iterations:        100
Instructions:      300
Total Cycles:      110
Total uOps:        500

Dispatch Width:    6
uOps Per Cycle:    4.55
IPC:               2.73
Block RThroughput: 1.0
```
Diffstat (limited to 'src/test/debuginfo/enum-thinlto.rs')
0 files changed, 0 insertions, 0 deletions