replace mul_const

This commit is contained in:
Dmitry Vagner 2022-10-18 12:47:31 -04:00
parent eb4f8fec45
commit 6451190d76
2 changed files with 28 additions and 26 deletions

View File

@ -17,15 +17,15 @@ return_on_stack:
/// macro | num | ops | cost /// macro | num | ops | cost
/// ------------------------- /// -------------------------
/// load | 8 | 40 | 320 /// load | 8 | 40 | 320
/// store | 5 | 40 | 200 /// store | 5 | 40 | 200
/// dup | 5 | 6 | 30 /// dup | 5 | 6 | 30
/// swap | 4 | 16 | 64 /// swap | 4 | 16 | 64
/// add | 3 | 16 | 48 /// add | 3 | 16 | 48
/// sub | 2 | 17 | 34 /// sub | 2 | 17 | 34
/// mul | 3 | 156 | 468 /// mul | 3 | 156 | 468
/// i9 | 1 | 9 | 9 /// i9 | 1 | 9 | 9
/// jump | 1 | 1 | 1 /// jump | 1 | 1 | 1
/// ///
/// TOTAL: 1174 /// TOTAL: 1174

View File

@ -84,6 +84,24 @@
// stack: // stack:
%endmacro %endmacro
// cost: 9; note this returns y, x for x + yi
%macro i9
// stack: a , b
DUP2
DUP2
// stack: a , b, a , b
PUSH 9
MULFP254
SUBFP254
// stack: 9a - b, a , b
SWAP2
// stack: b , a, 9a - b
PUSH 9
MULFP254
ADDFP254
// stack: 9b + a, 9a - b
%endmacro
// cost: 6 // cost: 6
%macro dup1_fp6 %macro dup1_fp6
// stack: f: 6 // stack: f: 6
@ -190,22 +208,6 @@
// stack: h0, h1, h2, h3, h4, h5 // stack: h0, h1, h2, h3, h4, h5
%endmacro %endmacro
// cost: 9; note this returns y, x for x + yi
%macro i9
// stack: a , b
DUP2
DUP2
// stack: a , b, a , b
%mul_const(9)
SUBFP254
// stack: 9a - b, a , b
SWAP2
// stack: b , a, 9a - b
%mul_const(9)
ADDFP254
// stack: 9b + a, 9a - b
%endmacro
// cost: 156 // cost: 156
%macro mul_fp6 %macro mul_fp6
/// E = E0 + E1t + E2t^2 = CD /// E = E0 + E1t + E2t^2 = CD
@ -379,7 +381,7 @@
ADDFP254 ADDFP254
ADDFP254 ADDFP254
SWAP13 SWAP13
/// E2 = C0D2 + C1D1 + C2D0 /// E2 = C0D2 + C1D1 + C2D0
/// ///
/// C0D2 = (c0d2 - c0_d2_) + (c0d2_ + c0_d2)i /// C0D2 = (c0d2 - c0_d2_) + (c0d2_ + c0_d2)i