0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
zig/src/Value.zig
lg 749ed5fc7f Sema: comptime arithmetic optimizations (#36495)
Tests heavy on comptime arithmetic show a ~7% improvement in wall-clock
time, and a ~11% improvement in peak RSS. There are two optimizations:

1. Avoid interning the overflow bit
Previously, the overflow bit was being interned and immediately read
back. Instead, a new OverflowArithmeticResultInt type is introduced that
contains the overflow result as a boolean directly. When converted, that boolean
points to the already existing zero_u1 and one_u1 interned values.

2. Try arithmetic operations without BigInt first.
This did not show significant performance improvements, but it did show a
significant memory usage improvement, almost going 0.5x! Instead of resorting to
BigInt first, arithmetic operations are tried in a u64.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/36495
Reviewed-by: mlugg <mlugg@mlugg.co.uk>
2026-08-31 11:48:29 +02:00

2580 lines
105 KiB