Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions zerocopy/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ These instructions apply to work in the `zerocopy/` subtree.
In Markdown, indent wrapped bullet continuation lines by two spaces and put a
blank line after each section heading.

- **Derived traits in tests:** For traits whose documentation requires
derive-only implementation, test fixture types **MUST** use Zerocopy's
derives. Do not bypass a derive rejection with a manual implementation;
instead, test the lower-level internal primitive or extend the derive.
Generated derive-output snapshots and crate-owned built-in implementations
are exempt.

## Task-Specific Skills

Use the applicable skills in addition to these standing rules. Skills compose;
Expand Down
31 changes: 15 additions & 16 deletions zerocopy/benches/ref_from_bytes_dynamic_padding.x86-64
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
bench_ref_from_bytes_dynamic_padding:
test dil, 3
jne .LBB5_3
movabs rax, 9223372036854775804
and rax, rsi
cmp rax, 9
jb .LBB5_3
add rax, -9
cmp rsi, 12
setae al
mov ecx, esi
or ecx, edi
test cl, 3
sete cl
and cl, al
cmp cl, 1
je .LBB5_2
xor edi, edi
mov rax, rdi
ret
.LBB5_2:
add rsi, -9
movabs rcx, -6148914691236517205
mov rax, rsi
mul rcx
shr rdx
lea rax, [rdx + 2*rdx]
or rax, 3
add rax, 9
cmp rsi, rax
je .LBB5_4
.LBB5_3:
xor edi, edi
mov rdx, rsi
.LBB5_4:
mov rax, rdi
ret
70 changes: 35 additions & 35 deletions zerocopy/benches/ref_from_bytes_dynamic_padding.x86-64.mca
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Iterations: 100
Instructions: 1900
Total Cycles: 645
Total Cycles: 641
Total uOps: 2000

Dispatch Width: 4
uOps Per Cycle: 3.10
IPC: 2.95
uOps Per Cycle: 3.12
IPC: 2.96
Block RThroughput: 5.0


Expand All @@ -18,23 +18,23 @@ Instruction Info:
[6]: HasSideEffects (U)

[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 test dil, 3
1 1 1.00 jne .LBB5_3
1 1 0.33 movabs rax, 9223372036854775804
1 1 0.33 and rax, rsi
1 1 0.33 cmp rax, 9
1 1 1.00 jb .LBB5_3
1 1 0.33 add rax, -9
1 1 0.33 cmp rsi, 12
1 1 0.50 setae al
1 1 0.33 mov ecx, esi
1 1 0.33 or ecx, edi
1 1 0.33 test cl, 3
1 1 0.50 sete cl
1 1 0.33 and cl, al
1 1 0.33 cmp cl, 1
1 1 1.00 je .LBB5_2
1 0 0.25 xor edi, edi
1 1 0.33 mov rax, rdi
1 1 1.00 U ret
1 1 0.33 add rsi, -9
1 1 0.33 movabs rcx, -6148914691236517205
1 1 0.33 mov rax, rsi
2 4 1.00 mul rcx
1 1 0.50 shr rdx
1 1 0.50 lea rax, [rdx + 2*rdx]
1 1 0.33 or rax, 3
1 1 0.33 add rax, 9
1 1 0.33 cmp rsi, rax
1 1 1.00 je .LBB5_4
1 0 0.25 xor edi, edi
1 1 0.33 mov rdx, rsi
1 1 0.33 mov rax, rdi
1 1 1.00 U ret

Expand All @@ -52,26 +52,26 @@ Resources:

Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 6.32 6.33 - 6.35 - -
- - 6.33 6.33 - 6.34 - -

Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.64 0.35 - 0.01 - - test dil, 3
- - - - - 1.00 - - jne .LBB5_3
- - 0.34 0.65 - 0.01 - - movabs rax, 9223372036854775804
- - 0.35 0.65 - - - - and rax, rsi
- - 0.33 0.34 - 0.33 - - cmp rax, 9
- - - - - 1.00 - - jb .LBB5_3
- - 0.35 - - 0.65 - - add rax, -9
- - 0.97 0.01 - 0.02 - - movabs rcx, -6148914691236517205
- - 1.00 1.00 - - - - mul rcx
- - 0.99 - - 0.01 - - shr rdx
- - 0.33 0.67 - - - - lea rax, [rdx + 2*rdx]
- - 0.34 0.66 - - - - or rax, 3
- - 0.33 0.66 - 0.01 - - add rax, 9
- - 0.01 0.99 - - - - cmp rsi, rax
- - - - - 1.00 - - je .LBB5_4
- - 0.99 - - 0.01 - - cmp rsi, 12
- - 1.00 - - - - - setae al
- - - 0.34 - 0.66 - - mov ecx, esi
- - - 0.99 - 0.01 - - or ecx, edi
- - - 1.00 - - - - test cl, 3
- - 0.67 - - 0.33 - - sete cl
- - - 1.00 - - - - and cl, al
- - - 1.00 - - - - cmp cl, 1
- - - - - 1.00 - - je .LBB5_2
- - - - - - - - xor edi, edi
- - 0.32 0.01 - 0.67 - - mov rdx, rsi
- - 0.02 0.34 - 0.64 - - mov rax, rdi
- - 0.66 - - 0.34 - - mov rax, rdi
- - - - - 1.00 - - ret
- - 0.35 0.01 - 0.64 - - add rsi, -9
- - 0.65 0.33 - 0.02 - - movabs rcx, -6148914691236517205
- - 0.01 0.33 - 0.66 - - mov rax, rsi
- - 1.00 1.00 - - - - mul rcx
- - 1.00 - - - - - shr rdx
- - - 0.33 - 0.67 - - mov rax, rdi
- - - - - 1.00 - - ret
21 changes: 6 additions & 15 deletions zerocopy/benches/ref_from_bytes_dynamic_size.x86-64
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
bench_ref_from_bytes_dynamic_size:
mov rdx, rsi
cmp rsi, 4
setb al
or al, dil
test al, 1
je .LBB5_2
mov ecx, edx
or ecx, edi
xor eax, eax
ret
.LBB5_2:
lea rcx, [rdx - 4]
mov rsi, rcx
and rsi, -2
add rsi, 4
shr rcx
xor eax, eax
cmp rdx, rsi
cmove rdx, rcx
sub rdx, 4
cmovb rdi, rax
shr rdx
test cl, 1
cmove rax, rdi
ret
58 changes: 21 additions & 37 deletions zerocopy/benches/ref_from_bytes_dynamic_size.x86-64.mca
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Iterations: 100
Instructions: 1800
Total Cycles: 704
Total uOps: 2000
Instructions: 1000
Total Cycles: 373
Total uOps: 1200

Dispatch Width: 4
uOps Per Cycle: 2.84
IPC: 2.56
Block RThroughput: 5.0
uOps Per Cycle: 3.22
IPC: 2.68
Block RThroughput: 3.0


Instruction Info:
Expand All @@ -19,21 +19,13 @@ Instruction Info:

[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rdx, rsi
1 1 0.33 cmp rsi, 4
1 1 0.50 setb al
1 1 0.33 or al, dil
1 1 0.33 test al, 1
1 1 1.00 je .LBB5_2
1 1 0.33 mov ecx, edx
1 1 0.33 or ecx, edi
1 0 0.25 xor eax, eax
1 1 1.00 U ret
1 1 0.50 lea rcx, [rdx - 4]
1 1 0.33 mov rsi, rcx
1 1 0.33 and rsi, -2
1 1 0.33 add rsi, 4
1 1 0.50 shr rcx
1 0 0.25 xor eax, eax
1 1 0.33 cmp rdx, rsi
2 2 0.67 cmove rdx, rcx
1 1 0.33 sub rdx, 4
2 2 0.67 cmovb rdi, rax
1 1 0.50 shr rdx
1 1 0.33 test cl, 1
2 2 0.67 cmove rax, rdi
1 1 1.00 U ret

Expand All @@ -51,25 +43,17 @@ Resources:

Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 5.97 5.98 - 6.05 - -
- - 3.66 3.67 - 3.67 - -

Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.97 0.01 - 0.02 - - mov rdx, rsi
- - 0.01 0.02 - 0.97 - - cmp rsi, 4
- - 0.03 - - 0.97 - - setb al
- - 0.01 0.02 - 0.97 - - or al, dil
- - - 0.98 - 0.02 - - test al, 1
- - - - - 1.00 - - je .LBB5_2
- - - - - - - - xor eax, eax
- - - - - 1.00 - - ret
- - 0.98 0.02 - - - - lea rcx, [rdx - 4]
- - 0.01 0.99 - - - - mov rsi, rcx
- - - 0.98 - 0.02 - - and rsi, -2
- - 0.98 0.01 - 0.01 - - add rsi, 4
- - 0.99 - - 0.01 - - shr rcx
- - 0.32 0.01 - 0.67 - - mov rdx, rsi
- - 0.33 0.35 - 0.32 - - mov ecx, edx
- - 0.01 0.34 - 0.65 - - or ecx, edi
- - - - - - - - xor eax, eax
- - 0.02 0.97 - 0.01 - - cmp rdx, rsi
- - 0.99 0.99 - 0.02 - - cmove rdx, rcx
- - 0.98 0.99 - 0.03 - - cmove rax, rdi
- - 0.67 0.33 - - - - sub rdx, 4
- - 0.99 0.98 - 0.03 - - cmovb rdi, rax
- - 0.03 - - 0.97 - - shr rdx
- - 0.32 0.67 - 0.01 - - test cl, 1
- - 0.99 0.99 - 0.02 - - cmove rax, rdi
- - - - - 1.00 - - ret
14 changes: 7 additions & 7 deletions zerocopy/benches/ref_from_prefix_dynamic_padding.x86-64
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
bench_ref_from_prefix_dynamic_padding:
test dil, 3
sete al
cmp rsi, 12
setae cl
test al, cl
jne .LBB5_2
movabs rax, 9223372036854775804
and rsi, rax
cmp rsi, 8
ja .LBB5_3
.LBB5_2:
xor edx, edx
test dil, 3
sete dl
xor edi, edi
mov rax, rdi
ret
.LBB5_3:
add rsi, -9
.LBB5_2:
or rsi, 3
add rsi, -12
movabs rcx, -6148914691236517205
mov rax, rsi
mul rcx
Expand Down
48 changes: 25 additions & 23 deletions zerocopy/benches/ref_from_prefix_dynamic_padding.x86-64.mca
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Iterations: 100
Instructions: 1900
Total Cycles: 607
Total uOps: 2000
Instructions: 2000
Total Cycles: 640
Total uOps: 2100

Dispatch Width: 4
uOps Per Cycle: 3.29
uOps Per Cycle: 3.28
IPC: 3.13
Block RThroughput: 5.0
Block RThroughput: 5.3


Instruction Info:
Expand All @@ -19,18 +19,19 @@ Instruction Info:

[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 test dil, 3
1 1 0.50 sete al
1 1 0.33 cmp rsi, 12
1 1 0.50 setae cl
1 1 0.33 test al, cl
1 1 1.00 jne .LBB5_2
1 1 0.33 movabs rax, 9223372036854775804
1 1 0.33 and rsi, rax
1 1 0.33 cmp rsi, 8
1 1 1.00 ja .LBB5_3
1 0 0.25 xor edx, edx
1 1 0.33 test dil, 3
1 1 0.50 sete dl
1 0 0.25 xor edi, edi
1 1 0.33 mov rax, rdi
1 1 1.00 U ret
1 1 0.33 add rsi, -9
1 1 0.33 or rsi, 3
1 1 0.33 add rsi, -12
1 1 0.33 movabs rcx, -6148914691236517205
1 1 0.33 mov rax, rsi
2 4 1.00 mul rcx
Expand All @@ -52,26 +53,27 @@ Resources:

Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 6.00 5.99 - 6.01 - -
- - 6.33 6.33 - 6.34 - -

Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.01 0.98 - 0.01 - - test dil, 3
- - 0.65 0.34 - 0.01 - - test dil, 3
- - 0.99 - - 0.01 - - sete al
- - 0.01 0.33 - 0.66 - - cmp rsi, 12
- - 0.34 - - 0.66 - - setae cl
- - 1.00 - - - - - test al, cl
- - - - - 1.00 - - jne .LBB5_2
- - 0.98 0.01 - 0.01 - - movabs rax, 9223372036854775804
- - 0.01 0.99 - - - - and rsi, rax
- - 0.01 0.99 - - - - cmp rsi, 8
- - - - - 1.00 - - ja .LBB5_3
- - - - - - - - xor edx, edx
- - 0.99 0.01 - - - - test dil, 3
- - 0.99 - - 0.01 - - sete dl
- - - 0.99 - 0.01 - - test dil, 3
- - - - - 1.00 - - sete dl
- - - - - - - - xor edi, edi
- - - 0.01 - 0.99 - - mov rax, rdi
- - - 1.00 - - - - mov rax, rdi
- - - - - 1.00 - - ret
- - 0.01 0.99 - - - - add rsi, -9
- - - 1.00 - - - - movabs rcx, -6148914691236517205
- - 1.00 - - - - - mov rax, rsi
- - 0.01 0.99 - - - - or rsi, 3
- - 0.33 0.67 - - - - add rsi, -12
- - 0.66 0.34 - - - - movabs rcx, -6148914691236517205
- - 0.34 0.33 - 0.33 - - mov rax, rsi
- - 1.00 1.00 - - - - mul rcx
- - 1.00 - - - - - shr rdx
- - - 0.01 - 0.99 - - mov rax, rdi
- - - 0.34 - 0.66 - - mov rax, rdi
- - - - - 1.00 - - ret
Loading
Loading