Subject: Re: bug#46540: 28.0.50; Native-comp optimization bug

From: Andrea Corallo <[email-masked]>
Date: Tue, 16 Feb 2021 21:43:29 +0000

Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <[email-masked]> writes:

> Yu Han Quek <[email-masked]> writes:
>
>> The following function gives an incorrect result when compiled natively
>> with comp-speed >= 2.
>>
>> ;; -*- lexical-binding: t; -*-
>>
>> (defun native-comp-bug (body)
>>   (let ((x (car body))
>>         (y (cadr body)))
>>     (unless (and
>>              (natnump x)
>>              (natnump y)
>>              (<= x y))
>>       (error ""))
>>     x))
>
> Cool thanks for the reduced reproducer!
>
> I'll have a in the coming days.
>
>   Andrea

Ok here a slightly simplified reproducer:

;; -*- lexical-binding: t; -*-
(defun native-comp-bug (x y)
  (if (and (natnump x)
           (natnump y)
           (<= x y))
      x
    (error "")))

The following constrain insn clearly resolves in the wrong way:

(assume #(mvar 79140560 0 (integer 0 0)) (<= #(mvar 79118120 0 (integer 0 *)) #(mvar 79118988 3 (integer 0 *))))

Will come-up with a fix.

  Andrea