Skip to content

impl shr in Arm assembly #798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

dvdplm
Copy link
Contributor

@dvdplm dvdplm commented Mar 28, 2025

As a follow-up to the conversation in #753, here's an implementation of right shift using Arm assembly. I don't suggest we ever merge this, but it does give us a way to measure the constant-time-ness of alternative impls, such as the one suggested in #753.

cc @erik-3milabs

On my mac the benchmarks numbers are:

right shift/shr, U2048  time:   [179.15 ns 180.23 ns 181.56 ns]
                        change: [+0.7871% +1.5747% +2.4028%] (p = 0.00 < 0.05)
                        Change within noise threshold.
right shift/shr, U2048, asm
                        time:   [30.854 ns 31.279 ns 31.621 ns]
                        change: [-3.8200% +0.3339% +5.0328%] (p = 0.88 > 0.05)
                        No change in performance detected.
Found 12 outliers among 100 measurements (12.00%)
  12 (12.00%) low mild
right shift/shr, U2048, zero
                        time:   [179.11 ns 180.27 ns 181.68 ns]
                        change: [-1.1264% +0.1229% +1.3662%] (p = 0.86 > 0.05)
                        No change in performance detected.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high severe
right shift/shr, U2048, zero, asm
                        time:   [30.943 ns 31.393 ns 31.753 ns]
                        change: [-2.1681% +2.2669% +6.7396%] (p = 0.32 > 0.05)
                        No change in performance detected.
Found 13 outliers among 100 measurements (13.00%)
  13 (13.00%) low mild
right shift/shr, U2048, mid
                        time:   [189.42 ns 190.02 ns 190.62 ns]
                        change: [-1.1437% -0.2175% +0.6928%] (p = 0.64 > 0.05)
                        No change in performance detected.
right shift/shr, U2048, mid, asm
                        time:   [27.971 ns 28.345 ns 28.677 ns]
                        change: [-6.0848% -2.5856% +0.9298%] (p = 0.16 > 0.05)
                        No change in performance detected.
right shift/shr, U2048, large
                        time:   [189.17 ns 189.88 ns 190.73 ns]
                        change: [-1.0664% -0.2413% +0.6037%] (p = 0.58 > 0.05)
                        No change in performance detected.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
right shift/shr, U2048, large, asm
                        time:   [28.857 ns 29.365 ns 29.835 ns]
                        change: [-2.7698% +0.8271% +4.5237%] (p = 0.66 > 0.05)
                        No change in performance detected.
Found 2 outliers among 100 measurements (2.00%)
  1 (1.00%) low mild
  1 (1.00%) high mild

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.

1 participant