From 756fa007bd8313514ddc45a4052d5bdc70ddea48 Mon Sep 17 00:00:00 2001 From: jsing Date: Thu, 5 Jan 2023 04:44:20 +0000 Subject: [PATCH] Add additional shift benchmarks that are useful on BN_BITS2 == 32 platforms --- regress/lib/libcrypto/bn/bn_shift.c | 58 ++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/regress/lib/libcrypto/bn/bn_shift.c b/regress/lib/libcrypto/bn/bn_shift.c index 743a911cbee..2335ae62128 100644 --- a/regress/lib/libcrypto/bn/bn_shift.c +++ b/regress/lib/libcrypto/bn/bn_shift.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_shift.c,v 1.5 2022/12/23 02:13:15 jsing Exp $ */ +/* $OpenBSD: bn_shift.c,v 1.6 2023/01/05 04:44:20 jsing Exp $ */ /* * Copyright (c) 2022 Joel Sing * @@ -391,6 +391,12 @@ benchmark_bn_lshift_1(BIGNUM *bn) benchmark_bn_lshift(bn, 1); } +static void +benchmark_bn_lshift_16(BIGNUM *bn) +{ + benchmark_bn_lshift(bn, 16); +} + static void benchmark_bn_lshift_32(BIGNUM *bn) { @@ -403,6 +409,18 @@ benchmark_bn_lshift_64(BIGNUM *bn) benchmark_bn_lshift(bn, 64); } +static void +benchmark_bn_lshift_65(BIGNUM *bn) +{ + benchmark_bn_lshift(bn, 65); +} + +static void +benchmark_bn_lshift_80(BIGNUM *bn) +{ + benchmark_bn_lshift(bn, 80); +} + static void benchmark_bn_lshift_127(BIGNUM *bn) { @@ -461,6 +479,18 @@ benchmark_bn_rshift_64(BIGNUM *bn) benchmark_bn_rshift(bn, 64); } +static void +benchmark_bn_rshift_65(BIGNUM *bn) +{ + benchmark_bn_rshift(bn, 65); +} + +static void +benchmark_bn_rshift_80(BIGNUM *bn) +{ + benchmark_bn_rshift(bn, 80); +} + static void benchmark_bn_rshift_127(BIGNUM *bn) { @@ -481,6 +511,10 @@ struct benchmark benchmarks[] = { .desc = "BN_lshift(_, _, 1)", .func = benchmark_bn_lshift_1, }, + { + .desc = "BN_lshift(_, _, 16)", + .func = benchmark_bn_lshift_16, + }, { .desc = "BN_lshift(_, _, 32)", .func = benchmark_bn_lshift_32, @@ -489,6 +523,14 @@ struct benchmark benchmarks[] = { .desc = "BN_lshift(_, _, 64)", .func = benchmark_bn_lshift_64, }, + { + .desc = "BN_lshift(_, _, 65)", + .func = benchmark_bn_lshift_65, + }, + { + .desc = "BN_lshift(_, _, 80)", + .func = benchmark_bn_lshift_80, + }, { .desc = "BN_lshift(_, _, 127)", .func = benchmark_bn_lshift_127, @@ -502,13 +544,25 @@ struct benchmark benchmarks[] = { .func = benchmark_bn_rshift_1, }, { - .desc = "BN_rshift(_, _, 32)", + .desc = "BN_rshift(_, _, 16)", + .func = benchmark_bn_rshift_32, + }, + { + .desc = "BN_rshift(_, _, 16)", .func = benchmark_bn_rshift_32, }, { .desc = "BN_rshift(_, _, 64)", .func = benchmark_bn_rshift_64, }, + { + .desc = "BN_rshift(_, _, 65)", + .func = benchmark_bn_rshift_65, + }, + { + .desc = "BN_rshift(_, _, 80)", + .func = benchmark_bn_rshift_80, + }, { .desc = "BN_rshift(_, _, 127)", .func = benchmark_bn_rshift_127, -- 2.20.1