3 ms·
rep movsb/rep movsd works well for moving data. However, you obviously can't use that approach for searching for a 0. That's why the code is optimized as it was
by axod 18y ago
rep movsb/rep movsd works well for moving data. However, you obviously can't use that approach for searching for a 0. That's why the code is optimized as it was. My point is that using rep scasb is suboptimal.
Don't know what you're talking about "lower cost to invoke the routine", and the cache/BTB entries would be negligible on a small routine like this.
You seem kinda angry and bitter whenever you reply to me :/ Chill out eh.
- tptacek 18y agoIt costs cycles to call a C function. I seem angry and bitter all the time. But my point is just, there's an argument in favor of scasb.
- axod 18y agoSo you're comparing inlined rep scasb, with non-inlined alternative. Interesting comparison I guess. Sure, it would bloat the code a little to inline the optimized version, but it could be done in tight inner loops if required.
- tptacek 18y agoI'm assuming you're not inlining a function with a loop in it, but OK, you can also just expand the 7 insns everywhere you call strlen.