MCPcopy Create free account
hub / github.com/JeanLucPons/VanitySearch / DivStep62

Function DivStep62

IntMod.cpp:110–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108// ------------------------------------------------
109
110inline void DivStep62(int64_t u0,int64_t v0,
111 int64_t* eta,
112 int64_t* uu,int64_t* uv,
113 int64_t* vu,int64_t* vv) {
114
115 // u' = (uu*u + uv*v) >> bitCount
116 // v' = (vu*u + vv*v) >> bitCount
117 // Do not maintain a matrix for r and s, the number of
118 // 'added P' can be easily calculated
119
120 int bitCount;
121
122#if 0
123
124 #define SWAP_ADD(x,y) x+=y;y-=x;
125 #define SWAP_SUB(x,y) x-=y;y+=x;
126
127 // Former divstep62 (using __builtin_ctzll)
128 // Do not use eta, u and v have an exponential decay in worst case
129 // but with low probability to reach this worst case complexity
130 // Avg: 581 Kinv/s
131
132 bitCount = 62;
133 int64_t nb0;
134
135 while(true) {
136
137 int zeros = __builtin_ctzll(v0 | (UINT64_MAX << bitCount));
138 v0 >>= zeros;
139 *uu <<= zeros;
140 *uv <<= zeros;
141 bitCount -= zeros;
142
143 if(bitCount <= 0)
144 break;
145
146 nb0 = (v0 + u0) & 0x3;
147 if(nb0 == 0) {
148 SWAP_ADD(*vv,*uv);
149 SWAP_ADD(*vu,*uu);
150 SWAP_ADD(v0,u0);
151 } else {
152 SWAP_SUB(*vv,*uv);
153 SWAP_SUB(*vu,*uu);
154 SWAP_SUB(v0,u0);
155 }
156
157 }
158
159
160#endif
161
162#if 1
163
164 #define SWAP_NEG(tmp,x,y) tmp = x; x = y; y = -tmp;
165
166 int64_t m,w,x,y,z;
167 bitCount = 62;

Callers 1

ModInvMethod · 0.85

Calls 1

__builtin_ctzllFunction · 0.85

Tested by

no test coverage detected