Yes, it would allow for early returns, but early returns only improve performance if it allows you to skip work that is more costly than having to flush and refill the CPU pipeline.
By introducing an early return you also limit the CPU in how much speculative work it can do and how much data it can fetch/store in anticipation for this work. It can also prevent SIMD optimizations by preventing it from doing batch processing as well as function inlining if the compiler isn't sure how to optimize your code due to added complexity.
Early returns are good for readable control flow but it can hurt data flow and thus shouldn't be used in tight loops.
Less instructions doesn't always mean less cycles.
View all comments
Show parent comment
3
u/B1anc Sep 03 '26
Yes, it would allow for early returns, but early returns only improve performance if it allows you to skip work that is more costly than having to flush and refill the CPU pipeline.
By introducing an early return you also limit the CPU in how much speculative work it can do and how much data it can fetch/store in anticipation for this work. It can also prevent SIMD optimizations by preventing it from doing batch processing as well as function inlining if the compiler isn't sure how to optimize your code due to added complexity.
Early returns are good for readable control flow but it can hurt data flow and thus shouldn't be used in tight loops.
Less instructions doesn't always mean less cycles.