MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / Multiply2Add

Method Multiply2Add

extra/yassl/taocrypt/src/integer.cpp:651–678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

649}
650
651word Portable::Multiply2Add(word *C, const word *A, const word *B)
652{
653 word D[4] = {A[1]-A[0], A[0]-A[1], B[0]-B[1], B[1]-B[0]};
654 unsigned int ai = A[1] < A[0];
655 unsigned int bi = B[0] < B[1];
656 unsigned int di = ai & bi;
657 DWord d = DWord::Multiply(D[di], D[di+2]);
658 D[1] = D[3] = 0;
659 unsigned int si = ai + !bi;
660 word s = D[si];
661
662 DWord A0B0 = DWord::Multiply(A[0], B[0]);
663 DWord t = A0B0 + C[0];
664 C[0] = t.GetLowHalf();
665
666 DWord A1B1 = DWord::Multiply(A[1], B[1]);
667 t = (DWord) t.GetHighHalf() + A0B0.GetLowHalf() + d.GetLowHalf() +
668 A1B1.GetLowHalf() + C[1];
669 C[1] = t.GetLowHalf();
670
671 t = (DWord) t.GetHighHalf() + A1B1.GetLowHalf() + A0B0.GetHighHalf() +
672 d.GetHighHalf() + A1B1.GetHighHalf() - s + C[2];
673 C[2] = t.GetLowHalf();
674
675 t = (DWord) t.GetHighHalf() + A1B1.GetHighHalf() + C[3];
676 C[3] = t.GetLowHalf();
677 return t.GetHighHalf();
678}
679
680
681#define MulAcc(x, y) \

Callers

nothing calls this directly

Calls 2

GetLowHalfMethod · 0.45
GetHighHalfMethod · 0.45

Tested by

no test coverage detected