Subject: Re: bug#36370: 27.0.50; XFIXNAT called on negative numbers

From: Pip Cet <[email-masked]>
Date: Thu, 27 Jun 2019 21:37:25 +0000

On Thu, Jun 27, 2019 at 9:13 PM Paul Eggert <[email-masked]> wrote:
> On 6/27/19 12:56 PM, Pip Cet wrote:
> > The eassume tells GCC i is nonnegative, since (!(i >= 0) == !(i >= 0))
> > is indeed a constant.
>
> Ah! Thanks, I didn't catch that subtle point. Would the attached patch
> to verify.h address that problem? This patch is for Gnulib, but would
> propagate into Emacs.

Eventually, I think that would be a good idea. But right now, I would
like to figure out why GCC isn't generating code that's as good as it
should be.

> I tried this out with Emacs master and although it did change the
> machine code subtly I didn't have the patience to see whether the
> changes were likely to improve performance. The changes did grow the
> Emacs text segment from 2556193 to 2557657 bytes (a 0.06% growth), which
> is not a good sign. This was on Fedora 30 x86-64 with a default Emacs build.

So far, what I've found is that

  eassume (0 <= i && i < bool_vector_size (a));

doesn't work with my patch. Tweaking that to

  eassume (0 <= i);
  eassume (i < bool_vector_size (a));

appears to help a little, but it's a good idea to avoid generating a
call to a function that might be out-lined by the compiler, in any
case.

One thing I've neglected to look at in detail, because Emacs isn't
affected by it, is how this works with pure functions.

> I'll CC: this to bug-gnulib since it's a Gnulib issue. I have not
> installed this patch into Gnulib on savannah.

I'd be extremely interested in any comments people might have!