Skip to content

Commit 5a6192f

Browse files
committed
silence warnings
1 parent 37127f0 commit 5a6192f

3 files changed

Lines changed: 27 additions & 16 deletions

File tree

bench/bench_bigint_montgomery.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include <benchmark/benchmark.h>
66

7+
#include <utility>
8+
79
#include <t81/t81lib.hpp>
810
#include <t81/util/random.hpp>
911

@@ -35,8 +37,8 @@ bench_bigint_div_mod(benchmark::State &state) {
3537
if (divisor.is_zero()) {
3638
divisor = t81::core::bigint::one();
3739
}
38-
const auto result = t81::core::bigint::div_mod(dividend, divisor);
39-
benchmark::DoNotOptimize(result);
40+
auto result = t81::core::bigint::div_mod(dividend, divisor);
41+
benchmark::DoNotOptimize(std::move(result));
4042
}
4143
}
4244

@@ -50,8 +52,8 @@ bench_montgomery_mul(benchmark::State &state) {
5052
const auto b = random_positive_bigint(rng, 2);
5153
const auto ma = context.to_montgomery(a);
5254
const auto mb = context.to_montgomery(b);
53-
const auto result = context.mul(ma, mb);
54-
benchmark::DoNotOptimize(result);
55+
auto result = context.mul(ma, mb);
56+
benchmark::DoNotOptimize(std::move(result));
5557
}
5658
}
5759

@@ -64,8 +66,8 @@ bench_montgomery_pow(benchmark::State &state) {
6466
while (state.KeepRunning()) {
6567
const auto base = random_positive_bigint(rng, 2);
6668
const auto mb = context.to_montgomery(base);
67-
const auto result = context.pow(mb, exponent);
68-
benchmark::DoNotOptimize(result);
69+
auto result = context.pow(mb, exponent);
70+
benchmark::DoNotOptimize(std::move(result));
6971
}
7072
}
7173

bench/bench_limb_add.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// bench/bench_limb_add.cpp — Benchmark for limb addition routines.
22

33
#include <random>
4+
#include <utility>
45

56
#include <benchmark/benchmark.h>
67

@@ -21,8 +22,8 @@ bench_limb_add(benchmark::State &state) {
2122
while (state.KeepRunning()) {
2223
const auto lhs = random_limb(rng);
2324
const auto rhs = random_limb(rng);
24-
const auto result = lhs + rhs;
25-
benchmark::DoNotOptimize(result);
25+
auto result = lhs + rhs;
26+
benchmark::DoNotOptimize(std::move(result));
2627
}
2728
}
2829

@@ -32,8 +33,9 @@ bench_limb_mul(benchmark::State &state) {
3233
while (state.KeepRunning()) {
3334
const auto lhs = random_limb(rng);
3435
const auto rhs = random_limb(rng);
35-
const auto product = t81::core::limb::mul_wide(lhs, rhs);
36-
benchmark::DoNotOptimize(product.first);
36+
auto product = t81::core::limb::mul_wide(lhs, rhs);
37+
auto product_value = product.first;
38+
benchmark::DoNotOptimize(std::move(product_value));
3739
}
3840
}
3941

bench/bench_numeric_types.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include <benchmark/benchmark.h>
44

5+
#include <utility>
6+
57
#include <t81/t81lib.hpp>
68

79
namespace {
@@ -17,8 +19,10 @@ namespace {
1719
const t81::Float rhs(make_limb(9), -2);
1820
for (auto _ : state) {
1921
auto product = lhs * rhs;
20-
benchmark::DoNotOptimize(product.mantissa());
21-
benchmark::DoNotOptimize(product.exponent());
22+
auto mantissa_value = product.mantissa();
23+
benchmark::DoNotOptimize(std::move(mantissa_value));
24+
auto exponent_value = product.exponent();
25+
benchmark::DoNotOptimize(std::move(exponent_value));
2226
}
2327
}
2428
BENCHMARK(BM_FloatMultiply);
@@ -29,8 +33,9 @@ namespace {
2933
for (auto _ : state) {
3034
auto sum = lhs + rhs;
3135
auto ordering = lhs <=> rhs;
32-
benchmark::DoNotOptimize(sum.numerator());
33-
benchmark::DoNotOptimize(ordering);
36+
auto numerator_value = sum.numerator();
37+
benchmark::DoNotOptimize(std::move(numerator_value));
38+
benchmark::DoNotOptimize(std::move(ordering));
3439
}
3540
}
3641
BENCHMARK(BM_RatioArithmetic);
@@ -42,7 +47,8 @@ namespace {
4247
for (auto _ : state) {
4348
auto result = left;
4449
result += right;
45-
benchmark::DoNotOptimize(result.to_limb());
50+
auto limb_value = result.to_limb();
51+
benchmark::DoNotOptimize(std::move(limb_value));
4652
}
4753
}
4854
BENCHMARK(BM_MontgomeryIntAdd);
@@ -54,7 +60,8 @@ namespace {
5460
for (auto _ : state) {
5561
auto result = left;
5662
result *= right;
57-
benchmark::DoNotOptimize(result.to_limb());
63+
auto limb_value = result.to_limb();
64+
benchmark::DoNotOptimize(std::move(limb_value));
5865
}
5966
}
6067
BENCHMARK(BM_MontgomeryIntMultiply);

0 commit comments

Comments
 (0)