From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.bugs Subject: bug#36370: 27.0.50; XFIXNAT called on negative numbers Date: Fri, 28 Jun 2019 13:51:24 +0000 Message-ID: References: <2715311.ceefYqj39C@omega> <8979488.cRkkfcT1mV@omega> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="183651"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 36370@debbugs.gnu.org, Paul Eggert , bug-gnulib@gnu.org To: Bruno Haible Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jun 28 17:11:17 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hgsWy-000lfL-AB for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Jun 2019 17:11:16 +0200 Original-Received: from localhost ([::1]:33042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgsWw-0007IA-6u for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Jun 2019 11:11:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32813) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgrJR-0008TD-DH for bug-gnu-emacs@gnu.org; Fri, 28 Jun 2019 09:53:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgrJL-0002ew-NH for bug-gnu-emacs@gnu.org; Fri, 28 Jun 2019 09:53:11 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55306) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hgrJG-0002Zk-Mr for bug-gnu-emacs@gnu.org; Fri, 28 Jun 2019 09:53:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hgrJG-0003Qm-IH for bug-gnu-emacs@gnu.org; Fri, 28 Jun 2019 09:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 28 Jun 2019 13:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36370 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 36370-submit@debbugs.gnu.org id=B36370.156172992913128 (code B ref 36370); Fri, 28 Jun 2019 13:53:02 +0000 Original-Received: (at 36370) by debbugs.gnu.org; 28 Jun 2019 13:52:09 +0000 Original-Received: from localhost ([127.0.0.1]:40617 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgrIP-0003Pg-DB for submit@debbugs.gnu.org; Fri, 28 Jun 2019 09:52:09 -0400 Original-Received: from mail-ot1-f49.google.com ([209.85.210.49]:46211) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgrIM-0003PC-Je for 36370@debbugs.gnu.org; Fri, 28 Jun 2019 09:52:07 -0400 Original-Received: by mail-ot1-f49.google.com with SMTP id z23so5990667ote.13 for <36370@debbugs.gnu.org>; Fri, 28 Jun 2019 06:52:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RGXOFred0FBkYFBeYkzA77sP/BTIEjMaTq55XuhOUq8=; b=V+nEYL16H0PhdnDTgOLZnd093IS7KH6SPZ6rO8YskJDdBhOfpqyo1U846+iQ0e9pf+ vdRpQXcuyzOyS983UyQbN8389xa/V2tbs8ul+MIbTPcZn6raAToluSUz8XY9PJFc0QGQ K6blUh1mYo5sAC/hB/JXKj7tMLUIsWwtfH7SsVAP2gd3ADGLxEYVuNMxpIH4r9jwJM87 M9MbV+bEWzeoMGGYoglAy7KB5lF10mUbre5apPqafzHYY8fYq0pDbBGQkoPfja7lKXt7 C2sKII7QmApKeivTxa/xrB9HC8tz1gcaI6qMDavGXBYbnnszscYlXsPuOfnFLG8EWSRD Cj/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RGXOFred0FBkYFBeYkzA77sP/BTIEjMaTq55XuhOUq8=; b=pWl3TyVqNWRi/D+U9JeR5OYOdhfE14HhxFSOpZwh4WhnLlsWbNmzziBrZlYZAxHowO l7TU+GbMOcy9VQFD7sU/c5N38nOmll3+V2yLwg1CRd5EraHv7+QYpccEhJIzV9+//xvK wmDdBfPyAOQ/J0h0OD2PG0YR1wakc7Kzk61R/N8EO+F8MPkh3ewe5RH/9weZh8P7JdgK Z02BRhNooC4h5cmsob7LYQKFT0JXBZCrRuYLvGPoGvluMUBMx7kcgDnOqxlIBufVDpfK Y1p5rdRugObO4QC/gOQQZHoAYqrInn4J01NSmphNkfvj5+xPd3yd3mkp7b3bPs8HaGls u+sg== X-Gm-Message-State: APjAAAUez8BCuzvtti4WNd/9tBJSdBKPSwe56Op3cElzsWpB0+p6RBlI 6N8gHLLFbBbE1RUuphpvXBmZR05Bb8YmDzoqXB4kVgX57sk= X-Google-Smtp-Source: APXvYqy/LQdJGQ/wMU01PQZFjx3bGbeU759EiH9qbC/uUK5Crcb8ojRtGNXRzUMGfcmTMIbyj6lzpHksgws5JMaILco= X-Received: by 2002:a9d:7352:: with SMTP id l18mr8485713otk.292.1561729920817; Fri, 28 Jun 2019 06:52:00 -0700 (PDT) In-Reply-To: <8979488.cRkkfcT1mV@omega> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:161730 Archived-At: On Fri, Jun 28, 2019 at 12:14 PM Bruno Haible wrote: > Pip Cet wrote: > > This makes it safe to use function expressions in eassume, whether the > > function is inlined or not. > > By "safe" you mean that you want the function call to not be evaluated. Sorry, sloppy wording there. You're right. > You are mentioning a limitation: > > > eassume(i >= 0 && i < complicated_function ()); > > > > will not "split" the && expression, so it'll behave differently from > > > > eassume(i >= 0); > > eassume(i < complicated_function ()); > > And I would mention a regression: When -flto is in use and the expression > invokes an external potentially-inlined function, the old 'assume' would > work fine, i.e. do optimizations across compilation-unit boundaries. Sorry, can't reproduce that here. I'm sure the changes I need to make are obvious once I've found them, but can you let me know your gcc version? > > But even in those cases, this approach is better than the old approach > > of actually evaluating complicated_function. > > I disagree that it is better: Sorry to be pedantic, but do you disagree that it is better in these cases, or in general? The latter is a question that I'm trying to find the answer to, but in these specific cases, it clearly is better. (Just in the interest of full disclosure, I described the idea in a different context; I think it's a neat hack, and I'm trying to figure out whether it has practical applications, but if it doesn't then I won't feel there's continuing disagreement). > 1. The new 'assume' is worse when -flto is in use. Maybe. Even if it is, though, that's a GCC limitation which I consider likely to be fixable; your estimation of that may vary, of course. > 2. You recommend to users to split assume(A && B) into assume(A); assume(B); > which is unnatural. I make that recommendation independently of which assume is in use. In practice, combining a complicated expression with a simple one in an eassume is almost always not what you want to do. It's way too easy to do something like eassume(ptr->field >= 0 && f(ptr)); when what you mean is eassume(ptr->field >= 0); eassume(f(ptr)); (As an unusual special case, consider: { printf("%d\n", i & 0x80000000); assume(i >= 0 && complicated_function()); } which would generate different code from { printf("%d\n", i & 0x80000000); assume(i >= 0); assume(complicated_function()); }) Combining two simple expressions and not getting the right result appears, at this point, to run into a GCC limitation, but I'm not sure where. > > At first, I thought it would be better to have a __builtin_assume > > expression at the GCC level, but even that would have to have "either > > evaluate the entire condition expression, or evaluate none of it" > > semantics. > > No. At GCC level, it could have a "make the maximum of inferences - across > all optimization phases -, but evaluate none of it" semantics. There's no contradiction there: I'm saying that the programmer is allowed to assume that the expression passed to assume either has been evaluated, or hasn't been, with no in-between interpretations allowed to the compiler. That means assume (A && B) isn't equivalent, in general, to assume (A); assume (B); My suspicion is that the latter is almost always what is intended.