| Zig's new bitCast semantics and LLVM back end improvements(ziglang.org) | |
| 248 points by kouosi 22 hours ago | 125 comments | |
tl;dr: Zig's `@bitCast` has been redefined with new semantics based on a type's "logical bit layout" rather than reinterpreting memory bytes, making behavior endian-agnostic and enabling operations like converting `[2]u3` to `@Vector(3, u2)`. The change was driven by LLVM backend improvements that now extend arbitrary bit-width integers (u4, u13, etc.) to ABI-sized types in memory—matching Clang's `_BitInt(N)` lowering—which restored missed optimizations and yielded ~5% performance gains in the Zig compiler itself. The new semantics are implemented across all backends and comptime execution, landing in 0.17.0. | |
HN Discussion:
| |