Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #66881 - krishna-veerareddy:issue-66780-bool-ord-opti…
…mization, 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 ```
- Loading branch information