Quadrupling code performance with a "useless" if
SMRTR summary
Adding a redundant conditional check around a memory write breaks data dependencies between loop iterations, letting the CPU exploit branch prediction for a 4x speedup. Use a volatile cast or `[[unlikely]]` to prevent the compiler from optimizing it away.
SMRTR provides this summary for quick context. The original article belongs to lobste.rs.
Read the original article