From c9dee6b54c2dc3b1812e5cc51fc210aac7bc6fb3 Mon Sep 17 00:00:00 2001 From: Ben Edgington Date: Sat, 6 Feb 2021 19:18:53 +0000 Subject: [PATCH] Implement optimisation suggestion from Mamy --- src/fft_fr.c | 5 ++--- src/fft_g1.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/fft_fr.c b/src/fft_fr.c index f3c4a15..bc6f07f 100644 --- a/src/fft_fr.c +++ b/src/fft_fr.c @@ -40,10 +40,9 @@ void fft_fr_fast(blst_fr *out, const blst_fr *in, uint64_t stride, const blst_fr fft_fr_fast(out + half, in + stride, stride * 2, roots, roots_stride * 2, half); for (uint64_t i = 0; i < half; i++) { blst_fr y_times_root; - blst_fr x = out[i]; blst_fr_mul(&y_times_root, &out[i + half], &roots[i * roots_stride]); - blst_fr_add(&out[i], &x, &y_times_root); - blst_fr_sub(&out[i + half], &x, &y_times_root); + blst_fr_sub(&out[i + half], &out[i], &y_times_root); + blst_fr_add(&out[i], &out[i], &y_times_root); } } else { fft_fr_slow(out, in, stride, roots, roots_stride, l); diff --git a/src/fft_g1.c b/src/fft_g1.c index 62cb85b..2e79f68 100644 --- a/src/fft_g1.c +++ b/src/fft_g1.c @@ -41,10 +41,9 @@ void fft_g1_fast(blst_p1 *out, blst_p1 *in, uint64_t stride, blst_fr *roots, uin fft_g1_fast(out + half, in + stride, stride * 2, roots, roots_stride * 2, half); for (uint64_t i = 0; i < half; i++) { blst_p1 y_times_root; - blst_p1 x = out[i]; p1_mul(&y_times_root, &out[i + half], &roots[i * roots_stride]); - blst_p1_add_or_double(&out[i], &x, &y_times_root); - p1_sub(&out[i + half], &x, &y_times_root); + p1_sub(&out[i + half], &out[i], &y_times_root); + blst_p1_add_or_double(&out[i], &out[i], &y_times_root); } } else { fft_g1_slow(out, in, stride, roots, roots_stride, l);