Remix.run Logo
btdmaster 5 hours ago

I see yeah that makes sense. I wanted to highlight that "magic" will, on average, give the optimizer a harder time. Explicit offset loops like that are generally avoided in many C++ styles in favor of iterators.

delta_p_delta_x 4 hours ago | parent [-]

Even at a higher level of abstraction, the compiler seems to pull through: https://godbolt.org/z/1nvE34YTe

btdmaster an hour ago | parent [-]

It emits a cmp/jmp still when arithmetic would be fine though which is the difference highlighted in the article and examples in this thread. It's nice that it simplifies down to assembly, but the assembly is somewhat questionable (especially that xor eax eax branch target on the other side).