3 ms·
Indeed. If unconditional branches are rare enough it may not be worth the cost. Also, it’s not like software designers don’t waste cycles. In many languages, f
by Someone 5y ago
Indeed. If unconditional branches are rare enough it may not be worth the cost.
Also, it’s not like software designers don’t waste cycles. In many languages, for example, arguments to log statements are evaluated even if logging is disabled. There sometimes is the hope that the runtime will figure that out and move that inside the if logging is enabled check, but that’s only a hope (COBOL had the ALTER statement for efficiently handling such things, but that’s being frowned upon :-))
Also: a conditional branch can be always taken, for example when the software does an if cpu supports instruction extension at startup, sets a flag accordingly, and later branches depending on that flag.
That, too, is a case where the CPU will speculatively execute what, to it, may look like garbage. So, you have to make sure speculative execution handles that.
- throwawaylinux 5y agoYep. Unconditional branches require BTB entries anyway if they're to be predicted ahead of decode, and if AMD's BTB was large and accurate enough then the incremental performance advantage of detecting not-taken direct branches after decode might not have been worthwhile. Security, sure arguably it could have been caught there. But Linux kernel development does not have the high ground when it comes to security problems.