Skip to content

Use inc reg instead of lea reg, [reg+1]. - #537

Draft
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_967687408
Draft

Use inc reg instead of lea reg, [reg+1].#537
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_967687408

Conversation

@copybara-service

Copy link
Copy Markdown

Use inc reg instead of lea reg, [reg+1].

With the path used before we had asm goto, we used setae
to mark overflow, and using inc would then cause a partial
flags stall. However, now we just use goto directly instead,
and this workaround is no longer relevant. Same with the
corresponding jnz/dec path.

The change was a ~25% win on the microbenchmarks when it was
originally rolled out; however, now changing it back has a
very small positive effect (Zen 2):

name cpu/op cpu/op vs base
BM_new_sized_delete/1 6.885n ± 0% 6.756n ± 1% -1.88% (p=0.000 n=50)
BM_new_sized_delete/8 6.909n ± 1% 6.889n ± 1% ~ (p=0.071 n=50)
BM_new_sized_delete/64 6.925n ± 0% 6.886n ± 1% ~ (p=0.161 n=50)
BM_new_sized_delete/512 7.292n ± 1% 7.369n ± 1% ~ (p=0.215 n=50)

With the path used before we had asm goto, we used setae
to mark overflow, and using inc would then cause a partial
flags stall. However, now we just use goto directly instead,
and this workaround is no longer relevant. Same with the
corresponding jnz/dec path.

The change was a ~25% win on the microbenchmarks when it was
originally rolled out; however, now changing it back has a
very small positive effect (Zen 2):

name                          cpu/op        cpu/op     vs base
BM_new_sized_delete/1         6.885n ± 0%   6.756n ±  1%  -1.88% (p=0.000 n=50)
BM_new_sized_delete/8         6.909n ± 1%   6.889n ±  1%       ~ (p=0.071 n=50)
BM_new_sized_delete/64        6.925n ± 0%   6.886n ±  1%       ~ (p=0.161 n=50)
BM_new_sized_delete/512       7.292n ± 1%   7.369n ±  1%       ~ (p=0.215 n=50)

PiperOrigin-RevId: 967687408
@google-cla

google-cla Bot commented Aug 20, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants