Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



It 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.


So 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.


I'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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: