From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] trunk r114593: * lisp.h (eassert): Don't use 'assume'. Date: Fri, 11 Oct 2013 08:42:20 -0400 Message-ID: References: <52576305.9000703@dancol.org> <52579C68.1040904@cs.ucla.edu> <83iox4pa0w.fsf@gnu.org> <5257AB8C.40309@dancol.org> <83eh7sp6v0.fsf@gnu.org> <5257B489.2050609@dancol.org> <87eh7si3ny.fsf@uwakimon.sk.tsukuba.ac.jp> <5257C083.5010909@dancol.org> <87a9ighzkp.fsf@uwakimon.sk.tsukuba.ac.jp> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1381495366 10420 80.91.229.3 (11 Oct 2013 12:42:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 11 Oct 2013 12:42:46 +0000 (UTC) Cc: Eli Zaretskii , Daniel Colascione , emacs-devel@gnu.org, eggert@cs.ucla.edu To: "Stephen J. Turnbull" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 11 14:42:49 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VUc3L-0001xP-9M for ged-emacs-devel@m.gmane.org; Fri, 11 Oct 2013 14:42:47 +0200 Original-Received: from localhost ([::1]:54119 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUc3K-0003oD-QA for ged-emacs-devel@m.gmane.org; Fri, 11 Oct 2013 08:42:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUc3A-0003nS-W4 for emacs-devel@gnu.org; Fri, 11 Oct 2013 08:42:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VUc33-0001Ei-Hv for emacs-devel@gnu.org; Fri, 11 Oct 2013 08:42:36 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:34113) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUc2v-0001E4-LZ; Fri, 11 Oct 2013 08:42:21 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFMCreE/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOkeoFegxM X-IPAS-Result: Av4EABK/CFFMCreE/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOkeoFegxM X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="35270500" Original-Received: from 76-10-183-132.dsl.teksavvy.com (HELO pastel.home) ([76.10.183.132]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 11 Oct 2013 08:38:29 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id A195860ED2; Fri, 11 Oct 2013 08:42:20 -0400 (EDT) In-Reply-To: <87a9ighzkp.fsf@uwakimon.sk.tsukuba.ac.jp> (Stephen J. Turnbull's message of "Fri, 11 Oct 2013 19:27:50 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:164093 Archived-At: > I've seen a lot of handwaving, but if there's a case where assume > helps the compiler produce better code in Emacs, I've yet to see it > presented. Indeed, the cases where the compiler can optimize the code based on the assume statement are fairly rare, because in most cases the programmer has already done most of this work by hand. I tend to agree with Daniel that `assert' should pretty much always be "assert + assume", in theory. In practice the fact that "assume" may occasionally have a cost, and the fact that it rarely offers further optimization opportunities, makes it less attractive than it appears at first. At the same time, this is all a tempest in a teapot: the difference is minuscule either way. Stefan PS: Cases where assert+assume could make a difference is if we only had (say) the CAR macro but not the XCAR macro, in which case an "assert+assume (CONSP (x))" could be used to tell the compiler that the type test embedded in CAR can be skipped. But of course, we don't trust the compiler to do this optimization for us, so instead we created the XCAR macro, at which point the "assert+assume (CONSP (x))" is no better than just "assert (CONSP (x))".