Branch prediction case study [Lightning Talk]
summary
Case study of a summing loop that tests values >128 shows surprising compiler effects: a StackOverflow example is compiled without a branch when the compiler emits cmovg conditional move, so sorted vs unsorted arrays show no difference on GCC 15.2 and MSVC. Older compilers keep a branch so sorted data runs about 2x faster on GCC 14.2, letting one estimate misprediction cost. Lesson: test on the target compiler and hardware and prefer branch-friendly code patterns.
AI-written summary · about
