DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 61RM0tg71796267 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 61RM0tg71796267 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=jqQTCA91 X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 218134BA23FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1772229654; bh=vD1u1/KIC0hmIPqvaLs6mpSKenfkPbCNsHWaYPllkTs=; h=Date:To:Cc:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=jqQTCA91Yn8HqFAk3au1vBBB+DZS4Z3HdkW9baHTvgJCI/BrjOeMguWV0RP5CBbNj R9/AGiCpoH2FjxYDQxrYzy9iwn6kNjuotWKqA8esbmTTQS7Qyu5aAbnK07mjectlPY I8FXLO5VxkPZXpzFvl//WP8/kAmncIfUgRBc5buA= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 922304BA23C8 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 922304BA23C8 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772229602; cv=none; b=F/mVYtFf5wtX/YVUbceWMqn1MJKpIwYvanH7RExfW9jmBfKHy2ptWisXMQmhtEX8Ybd1VwM/fm86qtwjBFKblClOzNOkk+ChU0Bp0dQvM0jjoVfP24Zx4yo6IeTlPbn1yfdeG37SbZi27sfb9+puf2smmidlU3OvXN6jpFoz0Y4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772229602; c=relaxed/simple; bh=pE7V7rGNEw8jwy8tZa6KdzTgJ2iRbBjAb2iWDBACMnU=; h=DKIM-Signature:Date:From:To:Message-ID:Subject:MIME-Version; b=Dfum16A87Gv3d2VSX3mtisFTBGAb295OnxTyqL8ts2zSjj1umSckqwO3DHbOrM0QAfCdBiCy3m1amBrbfLmqcRWnnm5PspTmtN8gUb36hkKMEeI1Zcm+sHCcqa/zczZvxtYetOrLrP3kcni3GtQds+ekhKtZ86arqq6i5EVeZk4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 922304BA23C8 Date: Fri, 27 Feb 2026 13:59:56 -0800 (PST) To: General Cygwin discussions and problem reports Cc: Brian Inglis Message-ID: <2015492551.1552309.1772229596693@connect.xfinity.com> In-Reply-To: <45c133f7-8285-4cb3-9701-2642cb76ab37@SystematicSW.ab.ca> References: <547312365 DOT 1464244 DOT 1771958282029 AT connect DOT xfinity DOT com> <1670201592 DOT 1489273 DOT 1772043520008 AT connect DOT xfinity DOT com> <1044918836 DOT 1507810 DOT 1772086967212 AT connect DOT xfinity DOT com> <1579472684 DOT 1508349 DOT 1772092747339 AT connect DOT xfinity DOT com> <1148572549 DOT 1808180 DOT 1772097444036 AT mail DOT yahoo DOT com> <1901597260 DOT 1508573 DOT 1772100378936 AT connect DOT xfinity DOT com> <0C965DD0-856E-41FF-B5A4-15E472292A32 AT unified-streaming DOT com> <483908609 DOT 1508714 DOT 1772103775739 AT connect DOT xfinity DOT com> <2346fd41-2500-0db6-5849-6788174b5a1d AT cs DOT umass DOT edu> <1462848037 DOT 1521935 DOT 1772136952077 AT connect DOT xfinity DOT com> <399745a1-429a-ebb4-0f67-c32f6282caa6 AT cs DOT umass DOT edu> <1093316506 DOT 1533154 DOT 1772157883568 AT connect DOT xfinity DOT com> <3e0de899-a7dd-8fea-7743-10e6b05cc6b6 AT cs DOT umass DOT edu> <1990836634 DOT 1545853 DOT 1772216419837 AT connect DOT xfinity DOT com> <45c133f7-8285-4cb3-9701-2642cb76ab37 AT SystematicSW DOT ab DOT ca> Subject: Re: Memmove causing program crashes, giving SIGTRAP in GDB(?) MIME-Version: 1.0 X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.6-Rev83 X-Originating-IP: ::ffff:50.47.202.14 X-Originating-Port: 18474 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfMXm+iWtk63ZG8XjsXjz26h5qgIL+lHjB1irLiEAHG6K2Lt01AQv39iZVbcfuR+Xz3QFE2EXEmGy3NkybpIgrvc3VVbPBVwUAot8Blvxei2eKmDenRJ2 E3/VYmncnbrJfAOKL3EOumJV9qOJvXWcLfXy/+iAwV5UIHU9Dkzz3wcAwPeP04JRg4Hd1xUueI5N4eiHWl83/yIF8LomS7rDN/P2cmykyYtAvsFOJE2DJI9J gjs1NWeUQ/zY0kPfRlDLse9L81vYVtSob18xO69PdUc= X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: KENNON J CONRAD via Cygwin Reply-To: KENNON J CONRAD Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Hi Brian, Thanks for replying. Is there a way to simplify to rep movsb (or movsw since the array is uint16_t) without using assembly code? The code is currently 100% C and I would prefer to avoid having a mix of C and assembly code. Also, it is unclear to me that even repsw would be faster than my bloated C code that generates assembly code that does 8 word moves in 5 instructions: .L25: movdqu -16(%rax), %xmm1 subq $16, %rax movups %xmm1, 2(%rax) cmpq %rdx, %rax jnb .L25 I am currently evaluating the stash and move method for the uint16_t data at the start that can't be moved in 16 byte chunks. It uses two extra 64 bit registers but that may be better than having the compiler move addresses into registers for a memmove call that moves the last 2 - 14 bytes (which is what the compiler does). I didn't think of that option until looking at the memmove assembly code. I thought alignment might be an issue, but noticed that the memmove assembly code does not perform alignment. It first checks the number of bytes to move. If the number of bytes to move is less than 8 it jumps to the movsb section. If the length is 8 or more it stashes the highest address bytes that need to be moved. Then it moves the data with rep movsq starting at the beginning or near the end (for backward moves) of the array, moving the data until the remaining length is less than 8 bytes (or 0 bytes for backward moves). Then it uses the stashed data to finish the move. The addresses for the rep movsq could have any alignment that is consistent with the alignment of the data being moved. Since this code is moving uint16_t's, the alignment is only 2 byte alignment for the rep movsq. At least if I am reading the assembly code correctly.... Best Regards, Kennon > On 02/27/2026 11:49 AM PST Brian Inglis via Cygwin wrote: > > > Hi Kennon, > > Some perf reports and analysis imply that backward moves (with overlap?) are no > faster than straight rep movsb on some CPUs, so it may be better to just > simplify to that, unless you want to stash the final element(s) to be moved out > of the way in register(s), and use multiple registers in unrolled wide moves for > the aligned portion? > -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple