Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: comp.arch Subject: Re: rep movsb vs. simpler instructions for memcpy/memmove Date: Thu, 13 Mar 2025 12:43:07 -0400 Organization: A noiseless patient Spider Lines: 17 Message-ID: References: <2025Mar4.110420@mips.complang.tuwien.ac.at> <2025Mar5.083636@mips.complang.tuwien.ac.at> <2025Mar12.094228@mips.complang.tuwien.ac.at> <20250312114828.00003e99@yahoo.com> <2025Mar12.122836@mips.complang.tuwien.ac.at> <20250312140915.000010a8@yahoo.com> <2025Mar12.174636@mips.complang.tuwien.ac.at> <61cab9791f342672dcbd5dfd539cc5cc@www.novabbs.org> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Thu, 13 Mar 2025 17:43:07 +0100 (CET) Injection-Info: dont-email.me; posting-host="8b299a8a9f11694663a9643fc779ea27"; logging-data="3670332"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lMU1HtWlDskG+P7Z31WcHh/YaiZg1Dtk=" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:3eZpPX8hCVM6CbhCaToBQJfYBtU= sha1:1d/5zS7VfdjiAcU7CegH7bi0Kew= Bytes: 2426 >> What is different about MM compared to `rep movsb` > MM does not modify the pointers. MM keeps its current index, > thus the compiler can use the Rf pointer multiple times. >> that you can confidently state that it will always be optimal? > Compared to the explosion in memmove() subroutine, yes. Are you suggesting that what prevents Intel to make `rep movsb` optimal is the fact that it modifies its pointers? I have no experience implementing such an instruction, but I find it odd that such a "cosmetic detail" would have such an profound impact on the performance of an instruction. Can't they just "macroexpand" it during decoding into two instructions (one which copies the bytes without modifying the pointers, and then one which just adjusts the pointers)? Stefan