|
|
|
|
|
by ot
4173 days ago
|
|
There's actually a huge difference: if you use __builtin_expect the slow path is still part of the function. If the fast path is small enough, you probably want to inline the function, but the slow path makes it large enough that the compiler doesn't inline it (for good reasons). If you force the slow path into a separate function, then your function becomes fast path + a call instruction, and it can be inlined. I've often done this manually, and this is a very cool trick that I'm going to adopt immediately. EDIT: plus, it's also beneficial for instruction cache/iTLB, as cornstalks pointed out. |
|