Subject: bug#62537: Error compiling emacs master with native compilation activated

From: Andrea Corallo <[email-masked]>
Date: Wed, 05 Apr 2023 21:12:09 +0000

Mattias Engdegård <[email-masked]> writes:

> 5 apr. 2023 kl. 19.19 skrev Andrea Corallo <[email-masked]>:
>
>> As we suspected was a bug in the native compiler limplification pass
>> triggered by the new LAP emitted.
>> 
>> fa669c4b17c fixes bootstrap --with-native-compilation=aot here and adds
>> a test, is now pushed to master.  In 29 the bug never showed up
>> (probably because the new LAP tweak is not it) so I guess it's better to
>> leave the code as it is.
>
> Nice! So the bug was that we optimised away switches where all jump targets are the same, without considering the fall-through case?

Hi Mattias,
yep that's correct :)

> (Perhaps we should do something like that in the LAP optimiser. Wonder how common the opportunity is though.)

Yeah might be a good idea even if I don't know how common this condition
is.  (We might count how many times `comp-jump-table-optimizable' returns
t in an aot build tho to get an idea).

> By the way, the bulk of `comp-jump-table-optimizable` should be equivalent to something like
>
>    (apply #'= (hash-table-values jmp-table))
>
> which is arguably clearer and definitely shorter.

True but with the downside that it conses.  I'll think about if I want
to change it, thanks for the neat suggestion tho :)

Best Regards

  Andrea