Commit 018262d537
Changed files (8)
lib
std
lib/std/crypto/aes/soft.zig
@@ -629,6 +629,8 @@ fn generateSbox(invert: bool) [256]u8 {
// Generate lookup tables.
fn generateTable(invert: bool) [4][256]u32 {
+ @setEvalBranchQuota(50000);
+
var table: [4][256]u32 = undefined;
for (generateSbox(invert), 0..) |value, index| {
lib/std/crypto/blake2.zig
@@ -786,7 +786,7 @@ test "blake2b384 streaming" {
test "comptime blake2b384" {
comptime {
- @setEvalBranchQuota(10000);
+ @setEvalBranchQuota(20000);
var block = [_]u8{0} ** Blake2b384.block_length;
var out: [Blake2b384.digest_length]u8 = undefined;
@@ -878,7 +878,7 @@ test "blake2b512 keyed" {
test "comptime blake2b512" {
comptime {
- @setEvalBranchQuota(10000);
+ @setEvalBranchQuota(12000);
var block = [_]u8{0} ** Blake2b512.block_length;
var out: [Blake2b512.digest_length]u8 = undefined;
lib/std/hash/xxhash.zig
@@ -890,7 +890,7 @@ test "xxhash32 smhasher" {
}
};
try Test.do();
- @setEvalBranchQuota(75000);
+ @setEvalBranchQuota(85000);
comptime try Test.do();
}
lib/std/math/hypot.zig
@@ -114,6 +114,7 @@ test "hypot.precise" {
}
test "hypot.special" {
+ @setEvalBranchQuota(2000);
inline for (.{ f16, f32, f64, f128 }) |T| {
try expect(math.isNan(hypot(nan(T), 0.0)));
try expect(math.isNan(hypot(0.0, nan(T))));
lib/std/math/nextafter.zig
@@ -144,7 +144,7 @@ test "int" {
}
test "float" {
- @setEvalBranchQuota(3000);
+ @setEvalBranchQuota(4000);
// normal -> normal
try expect(nextAfter(f16, 0x1.234p0, 2.0) == 0x1.238p0);
lib/std/enums.zig
@@ -6,7 +6,7 @@ const testing = std.testing;
const EnumField = std.builtin.Type.EnumField;
/// Increment this value when adding APIs that add single backwards branches.
-const eval_branch_quota_cushion = 5;
+const eval_branch_quota_cushion = 10;
/// Returns a struct with a field matching each unique named enum element.
/// If the enum is extern and has multiple names for the same value, only
lib/std/math.zig
@@ -749,31 +749,23 @@ test rotl {
try testing.expect(rotl(@Vector(1, u32), @Vector(1, u32){1 << 31}, @as(isize, -1))[0] == @as(u32, 1) << 30);
}
-/// Returns an unsigned int type that can hold the number of bits in T
-/// - 1. Suitable for 0-based bit indices of T.
+/// Returns an unsigned int type that can hold the number of bits in T - 1.
+/// Suitable for 0-based bit indices of T.
pub fn Log2Int(comptime T: type) type {
// comptime ceil log2
if (T == comptime_int) return comptime_int;
- comptime var count = 0;
- comptime var s = @typeInfo(T).Int.bits - 1;
- inline while (s != 0) : (s >>= 1) {
- count += 1;
- }
-
- return std.meta.Int(.unsigned, count);
+ const bits: u16 = @typeInfo(T).Int.bits;
+ const log2_bits = 16 - @clz(bits - 1);
+ return std.meta.Int(.unsigned, log2_bits);
}
/// Returns an unsigned int type that can hold the number of bits in T.
pub fn Log2IntCeil(comptime T: type) type {
// comptime ceil log2
if (T == comptime_int) return comptime_int;
- comptime var count = 0;
- comptime var s = @typeInfo(T).Int.bits;
- inline while (s != 0) : (s >>= 1) {
- count += 1;
- }
-
- return std.meta.Int(.unsigned, count);
+ const bits: u16 = @typeInfo(T).Int.bits;
+ const log2_bits = 16 - @clz(bits);
+ return std.meta.Int(.unsigned, log2_bits);
}
/// Returns the smallest integer type that can hold both from and to.
lib/std/unicode.zig
@@ -535,6 +535,7 @@ fn testUtf16CountCodepoints() !void {
}
test "utf16 count codepoints" {
+ @setEvalBranchQuota(2000);
try testUtf16CountCodepoints();
try comptime testUtf16CountCodepoints();
}