The main changes are:
Unrolling the inner rounds of salsa20_wordtobyte which doubles the speed.
Passing the slice explicitly instead of returning the array saves a copy (can optimize out in future with copy elision) and gives ~10% improvement.
Inlining the outer loop gives ~15-20% improvement but it costs an extra 4Kb of code space. I think the tradeoff is worthwhile here.
The other inline loops are small and can be done by the compiler if it is worthwhile.
The rotate function replacement doesn't alter the performance from the former.
The modified throughput test I've used to benchmark is as follows. Interestingly we need to allocate memory instead of using a fixed buffer else Zig optimizes the whole thing out.
https://github.com/ziglang/zig/pull/1369#issuecomment-416456628