about summary refs log tree commit diff
path: root/tests/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-08-16 08:43:49 +0200
committerGitHub <noreply@github.com>2023-08-16 08:43:49 +0200
commit4b2d87d82c5fd882fd9442c5ec2fb4867d37ef78 (patch)
tree1056a7dd2453cd04ab9437873aa8f520e46a139d /tests/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs
parent4e3ce0e782a30d467ddbc542c3eb5d215eac1b9d (diff)
parentb75351e98ee0a33dbd4dfe2b40e54e191d16dde5 (diff)
downloadrust-4b2d87d82c5fd882fd9442c5ec2fb4867d37ef78.tar.gz
rust-4b2d87d82c5fd882fd9442c5ec2fb4867d37ef78.zip
Rollup merge of #114721 - danflapjax:bool-ord-optimization, r=cuviper
Optimizing the rest of bool's Ord implementation

After coming across issue #66780, I realized that the other functions provided by Ord (`min`, `max`, and `clamp`) were similarly inefficient for bool. This change provides implementations for them in terms of boolean operators, resulting in much simpler assembly and faster code.
Fixes issue #114653

[Comparison on Godbolt](https://rust.godbolt.org/z/5nb5P8e8j)

`max` assembly before:
```assembly
example::max:
        mov     eax, edi
        mov     ecx, eax
        neg     cl
        mov     edx, esi
        not     dl
        cmp     dl, cl
        cmove   eax, esi
        ret
```
`max` assembly after:
```assembly
example::max:
        mov     eax, edi
        or      eax, esi
        ret
```
`clamp` assembly before:
```assembly
example::clamp:
        mov     eax, esi
        sub     al, dl
        inc     al
        cmp     al, 2
        jae     .LBB1_1
        mov     eax, edi
        sub     al, sil
        movzx   ecx, dil
        sub     dil, dl
        cmp     dil, 1
        movzx   edx, dl
        cmovne  edx, ecx
        cmp     al, -1
        movzx   eax, sil
        cmovne  eax, edx
        ret
.LBB1_1:
        ; identical assert! code
```
`clamp` assembly after:
```assembly
example::clamp:
        test    edx, edx
        jne     .LBB1_2
        test    sil, sil
        jne     .LBB1_3
.LBB1_2:
        or      dil, sil
        and     dil, dl
        mov     eax, edi
        ret
.LBB1_3:
        ; identical assert! code
```
Diffstat (limited to 'tests/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs')
0 files changed, 0 insertions, 0 deletions