3 ms·
Andrew’s point is that marking the memory as volatile should prevent this optimization. (i.e. the compiler isn’t allowed to split a 16-bit volatile write into t
by MatthiasPortzel 2y ago
Andrew’s point is that marking the memory as volatile should prevent this optimization. (i.e. the compiler isn’t allowed to split a 16-bit volatile write into two 8-but writes.) This is idiomatic because volatile is intended for MMIO.
There’s a proposal for a way to disable LLVM generating builtin calls like memcpy. But I’d argue volatile would still be more appropriate in this case.
https://github.com/ziglang/zig/issues/22110 https://github.com/ziglang/zig/issues/22110
Edit: this comment from later in the thread is also relevant:
https://news.ycombinator.com/item?id=42556624 https://news.ycombinator.com/item?id=42556624