From 1a0da46fd339665e390059582bbe5562be5793dd Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Tue, 6 Nov 2018 10:46:55 +0900 Subject: [PATCH] add Fp2::neg for bls12 --- src/fp_generator.hpp | 13 ++++--------- test/bls12_test.cpp | 3 +-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/fp_generator.hpp b/src/fp_generator.hpp index 22692f3..b74552b 100644 --- a/src/fp_generator.hpp +++ b/src/fp_generator.hpp @@ -3632,19 +3632,14 @@ private: { align(16); void2u func = getCurr(); - if (pn_ == 4 && !isFullBit_) { - gen_fp2_neg4(); + if (pn_ <= 6) { + StackFrame sf(this, 2, UseRDX | pn_); + gen_raw_neg(sf.p[0], sf.p[1], sf.t); + gen_raw_neg(sf.p[0] + FpByte_, sf.p[1] + FpByte_, sf.t); return func; } return 0; } - void gen_fp2_neg4() - { - assert(!isFullBit_); - StackFrame sf(this, 2, UseRDX | pn_); - gen_raw_neg(sf.p[0], sf.p[1], sf.t); - gen_raw_neg(sf.p[0] + FpByte_, sf.p[1] + FpByte_, sf.t); - } void3u gen_fp2_mul() { align(16); diff --git a/test/bls12_test.cpp b/test/bls12_test.cpp index 8722e76..c558d6b 100644 --- a/test/bls12_test.cpp +++ b/test/bls12_test.cpp @@ -700,8 +700,7 @@ if(0){ puts("----------"); // exit(1); } - CYBOZU_BENCH_C("Fp2::add", 10000000, Fp2::add, x2, x2, y2); - CYBOZU_BENCH_C("Fp2::sub", 10000000, Fp2::sub, x2, x2, y2); + CYBOZU_BENCH_C("Fp2::neg", 10000000, Fp2::neg, x2, x2); // CYBOZU_BENCH_C("mulPre", 100000000, FpDbl::mulPre, dx, xv[0], yv[0]); // CYBOZU_BENCH_C("sqrPre", 100000000, FpDbl::sqrPre, dx, xv[0]); // CYBOZU_BENCH_C("mod ", 100000000, FpDbl::mod, xv[0], dx);