freemint / mintlib

libc variant for TOS and FreeMiNT OS
GNU General Public License v2.0
22 stars 11 forks source link

Does a4 have to be sacrificed in bzero/bcopy? #82

Open mikrosk opened 2 days ago

mikrosk commented 2 days ago

Both bzero and bcopy contains same comment: https://github.com/freemint/mintlib/blob/dbfab2d80bd265e2c537f179ccf26f1747a73b01/string/bzero.S#L92 https://github.com/freemint/mintlib/blob/dbfab2d80bd265e2c537f179ccf26f1747a73b01/string/bcopy.S#L97 essentially crippling performance with omitting a4 register in the copy loop. Is this still relevant? It has been there since the initial revision.

th-otto commented 2 days ago

I think its not relevant for us (maybe it was based on some amiga example). We don't have any libraries that are compiled with -mbaserel, and even if we have, i guess there will be other places where a4 is not preserved in assembler code.

But does it really cripple performance? Instead of copying 5*44+36 bytes, you could then copy/zero 5*48+16 bytes, but that are still 6 movem.

mikrosk commented 1 day ago

But does it really cripple performance? Instead of copying 5*44+36 bytes, you could then copy/zero 5*48+16 bytes, but that are still 6 movem.

Hmm, true. I guess this could pay off in case we unroll the loop for 512B blocks.