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: Thu, 27 Jun 2019 19:56:17 +0000 Message-ID: References: <7ef599ae-0a1d-e86f-2bed-a1503455833f@cs.ucla.edu> 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="210703"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 36370-done@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 27 21:57:18 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 1hgaWD-000sgE-67 for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Jun 2019 21:57:17 +0200 Original-Received: from localhost ([::1]:54016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgaWC-0007fo-0Q for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Jun 2019 15:57:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38714) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgaVz-0007fd-VY for bug-gnu-emacs@gnu.org; Thu, 27 Jun 2019 15:57:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgaVy-0003YO-SY for bug-gnu-emacs@gnu.org; Thu, 27 Jun 2019 15:57:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54477) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hgaVy-0003XX-Fr for bug-gnu-emacs@gnu.org; Thu, 27 Jun 2019 15:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hgaVy-0004IQ-D6 for bug-gnu-emacs@gnu.org; Thu, 27 Jun 2019 15:57: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: Thu, 27 Jun 2019 19:57: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-done@debbugs.gnu.org id=D36370.156166542116506 (code D ref 36370); Thu, 27 Jun 2019 19:57:02 +0000 Original-Received: (at 36370-done) by debbugs.gnu.org; 27 Jun 2019 19:57:01 +0000 Original-Received: from localhost ([127.0.0.1]:39788 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgaVx-0004IA-5t for submit@debbugs.gnu.org; Thu, 27 Jun 2019 15:57:01 -0400 Original-Received: from mail-ot1-f50.google.com ([209.85.210.50]:45348) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgaVv-0004Hv-6L for 36370-done@debbugs.gnu.org; Thu, 27 Jun 2019 15:57:00 -0400 Original-Received: by mail-ot1-f50.google.com with SMTP id x21so3537661otq.12 for <36370-done@debbugs.gnu.org>; Thu, 27 Jun 2019 12:56:59 -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=5aM9A4uRXv4Vo6JN3eKAAAQruxCdKG9C9bRfk7Z1sOk=; b=Mxxaeg/8KnxHRk6JxXyDSde+7TUUJ46omVYJzx5yIbeuZAymTPK9OzokgA6spyHF75 h+3EOuuEZOccJ1ohGHJ3i8WxQwDHj5UiLI25Tr1fQbXfJIpDOInS2VuQKU9pJP3eM58E 7VfeUxYwxI4A0DTWKtQTsjuWUDpHHrKhX85idvB1NbETopfXhKRf1z3QwECpJg+sss2+ Xg0H6DPh+AOoGubwtamRev5gorSbaDn6MFsGXxSjMz7XFcPjzlZUnEUFvD0PvqEMup9b BxyM8jgrPrK/SAk7c1DyBCoFbbjJ9oTdvbHH+noALERv1edmKw7XVpEmSqRgWQDYXpar EwUA== 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=5aM9A4uRXv4Vo6JN3eKAAAQruxCdKG9C9bRfk7Z1sOk=; b=MUfNEv3q6VxbcwM2NkUuPMJCBbEKqAOyuQQxoK5A6LF+a3Ubh5zbRvmcvlkRNWvSfk he9af/0qmne6zC8P2+DzrfF4vGJXsyXg5TxegbuB0WwKaRpuFkdsVf5DZL/p04TqMLy3 qeQcr7EGbvbCFoUrLz1q9JRucmyAuICkkX/dDdo9xB5kXrrNK69GsPZFMSAfBXz1r1up A6AGmSIQraEbeUqH8IegSO4uUJN4aEC3J05y2Q6i1k80yywsLbUBCHcoEg9Nj9EfbFu2 3UcgR0LahQi9LiBbb6x7L/gESZ+49d2dt8VLmiLYzFwOJYnTiAs24FyG3IPV288O+gYC 4qjg== X-Gm-Message-State: APjAAAXcZqneg6ySPAuWgvpu4zojulwwxU1SNWU7upGJYleIH6uXjpbw CAGS+cZpY/4gHw3wEoRlKs5qksCNkOSIsPTpMDQ= X-Google-Smtp-Source: APXvYqxPCiC5ASwF83K6/7VVCG78Pnj23Z+25nvCPrQ6li3m2Z9Df+aT4j2h9/vPGtqG5TSIJe+2cf80TIqUCdklNbk= X-Received: by 2002:a9d:7284:: with SMTP id t4mr5338119otj.154.1561665413463; Thu, 27 Jun 2019 12:56:53 -0700 (PDT) In-Reply-To: <7ef599ae-0a1d-e86f-2bed-a1503455833f@cs.ucla.edu> 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:161651 Archived-At: On Thu, Jun 27, 2019 at 7:38 PM Paul Eggert wrote: > >> if it were up to me we'd get rid of XFIXNAT entirely, > >> and just use XFIXNUM. But old habits die hard.... > > > > I actually think that would be best, so we're only disagreeing about > > what the second-best solution is :-) > > Removing XFIXNAT would be outside the scope of this patch. However, if > we're already fixing the code for some other reason and if the XFIXNATs > are confusing that code, we might as well replace them with XFIXNUMs. > The attached patch does that. Cool! > > My idea is to define eassume as follows: > > > > #define eassume(cond) (__builtin_constant_p (!(cond) == !(cond)) ? > > ((cond) ? 0 : __builtin_unreachable ()) : 0) > > That would generate worse code in some cases, since after (say) "eassume > (i >= 0); return i/2;" where i is a variable, GCC would not be able to > optimize i/2 into i>>1 because GCC would not know that i is nonnegative. I'm confused, and I'm not sure what you're saying. int f (int i) { eassume (i >= 0); printf("%d\n", i & 0x80000000); return 0; } The eassume tells GCC i is nonnegative, since (!(i >= 0) == !(i >= 0)) is indeed a constant. So the code generated is: xorl %esi, %esi movl $.LC0, %edi xorl %eax, %eax call printf which is as it should be. For your example, it is: movl %edi, %eax sarl %eax ret with the eassume and movl %edi, %eax shrl $31, %eax addl %edi, %eax sarl %eax ret without. > The main point of eassume (as opposed to eassert) is to enable > optimizations like that. Yes, indeed. I don't see how they are disabled by my proposed definition. > Thanks for the review. In addition to the already-mentioned patches, I > installed the attached and am closing the bug report. Thanks!