From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#46111: Reverting fns.c hash function due to OpenBSD/SPARC64 compile breaking Date: Thu, 28 Jan 2021 19:22:47 +0200 Message-ID: <83zh0tx9g8.fsf@gnu.org> References: <87sg6oyzi6.wl-me@enzu.ru> <6915951F-2A53-4B08-A48A-6683B99AA14A@gnu.org> <871re5vh7a.fsf@ultra.enzu.ru> <8335ylytpf.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15316"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 46111@debbugs.gnu.org, me@enzu.ru To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 28 18:28:24 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l5B5j-0003qQ-Ic for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 28 Jan 2021 18:28:23 +0100 Original-Received: from localhost ([::1]:59758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5B5i-0003pN-Gv for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 28 Jan 2021 12:28:22 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5B0Z-0007oP-Te for bug-gnu-emacs@gnu.org; Thu, 28 Jan 2021 12:23:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38324) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5B0Y-00014x-A9 for bug-gnu-emacs@gnu.org; Thu, 28 Jan 2021 12:23:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l5B0Y-0005AC-6G for bug-gnu-emacs@gnu.org; Thu, 28 Jan 2021 12:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 28 Jan 2021 17:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46111 X-GNU-PR-Package: emacs Original-Received: via spool by 46111-submit@debbugs.gnu.org id=B46111.161185456219805 (code B ref 46111); Thu, 28 Jan 2021 17:23:02 +0000 Original-Received: (at 46111) by debbugs.gnu.org; 28 Jan 2021 17:22:42 +0000 Original-Received: from localhost ([127.0.0.1]:49870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l5B0E-00059N-1I for submit@debbugs.gnu.org; Thu, 28 Jan 2021 12:22:42 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:35352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l5B0B-000599-DI for 46111@debbugs.gnu.org; Thu, 28 Jan 2021 12:22:40 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:47624) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5B05-0000x8-US; Thu, 28 Jan 2021 12:22:33 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2005 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l5B04-0005s8-Ud; Thu, 28 Jan 2021 12:22:33 -0500 In-Reply-To: (message from Stefan Monnier on Thu, 28 Jan 2021 11:17:31 -0500) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:198812 Archived-At: > From: Stefan Monnier > Date: Thu, 28 Jan 2021 11:17:31 -0500 > Cc: 46111@debbugs.gnu.org > > + /* Here `p` is *almost* always be properly aligned, so we want to > + optimize for the aligned case, but we still need to support the > + non-aligned case. */ > + /* FIXME: Could we just always use `memcpy` and rely on GCC optimizing > + it to a single word-sized memory access on all-but-sparc64? */ > +#ifdef __sparc64__ /* Arch that still insists on aligned memory accesses. */ > + EMACS_UINT c; > + if (!((unsigned long)p) % sizeof (c)) > + c = *p; > + else > + memcpy (&c, (char const *)p, sizeof (c)); /* `p` is unaligned! */ > +#else > EMACS_UINT c = *p; > +#fi AFAIK, memcpy itself optimizes: once it gets to aligned address, it starts copying words instead of bytes. So I'm not sure we need either #ifdef or the run-time condition. I suggest to time both variants on x86 architecture, to see whether there's any performance hit due to use of memcpy, and if not, use memcpy always -- it will let us have the cake and eat it, too.