authorgravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2023-02-04 10:58:03+13:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-02-04 00:29:04-05:00
log4009e0d2b1ac5b0a9a0caff676d5c73ae18c6e9e
tree77ec981ac2d71d7e20a053d491f5c9cdaaac3d3e
parentc9b957c937ef457083f1a00c1343239086ef8796

remove stage1 workaround for big int set

Underlying fix should have been https://github.com/ziglang/zig/commit/d7b029995c8ac678598de39aa106076dca232902. u128 limb sizes are still not fully tested as we are missing compiler-rt support (__divei4, __modei4 on x86_64). Should be no zig blockers so the assertion has been removed.

2 files changed, 3 insertions(+), 9 deletions(-)

lib/std/math/big.zig-1
......@@ -13,7 +13,6 @@ pub const Log2Limb = std.math.Log2Int(Limb);
1313
1414comptime {
1515 assert(std.math.floorPowerOfTwo(usize, limb_info.bits) == limb_info.bits);
16 assert(limb_info.bits <= 64); // u128 set is unsupported
1716 assert(limb_info.signedness == .unsigned);
1817}
1918
lib/std/math/big/int.zig+3-8
......@@ -30,7 +30,7 @@ pub fn calcLimbLen(scalar: anytype) usize {
3030 }
3131
3232 const w_value = std.math.absCast(scalar);
33 return @divFloor(@intCast(Limb, math.log2(w_value)), limb_bits) + 1;
33 return @intCast(usize, @divFloor(@intCast(Limb, math.log2(w_value)), limb_bits) + 1);
3434}
3535
3636pub fn calcToStringLimbsBufferLen(a_len: usize, base: u8) usize {
......@@ -238,10 +238,7 @@ pub const Mutable = struct {
238238 var i: usize = 0;
239239 while (true) : (i += 1) {
240240 self.limbs[i] = @truncate(Limb, w_value);
241
242 // TODO: shift == 64 at compile-time fails. Fails on u128 limbs.
243 w_value >>= limb_bits / 2;
244 w_value >>= limb_bits / 2;
241 w_value >>= limb_bits;
245242
246243 if (w_value == 0) break;
247244 }
......@@ -258,9 +255,7 @@ pub const Mutable = struct {
258255 comptime var i = 0;
259256 inline while (true) : (i += 1) {
260257 self.limbs[i] = w_value & mask;
261
262 w_value >>= limb_bits / 2;
263 w_value >>= limb_bits / 2;
258 w_value >>= limb_bits;
264259
265260 if (w_value == 0) break;
266261 }