guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.6-31-g24


From: Mark H Weaver
Subject: Re: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.6-31-g2446f8e
Date: Mon, 08 Oct 2012 00:42:25 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Hi Ludovic,

> commit 2446f8e126d9a7c145c4868f2a918d2dfb226d4e
> Author: Ludovic Courtès <address@hidden>
> Date:   Sat Oct 6 01:24:46 2012 +0200
>
>     Simplify calls to `equal?' when one argument is a constant.
>     
>     * module/language/tree-il/primitives.scm (*primitive-expand-table*): Add
>       expansion rules for `equal?', when called with one constant and
>       another argument.
>     
>     * test-suite/tests/tree-il.test (pass-if-primitives-resolved): New
>       macro.
>       ("primitives"): New test prefix.

This commit has some problems.

> diff --git a/module/language/tree-il/primitives.scm 
> b/module/language/tree-il/primitives.scm
> index a1c5adc..dc0a145 100644
> --- a/module/language/tree-il/primitives.scm
> +++ b/module/language/tree-il/primitives.scm
> @@ -491,6 +491,33 @@
>    (bytevector-ieee-double-native-set! vec (* i 8) x))
>  
>  (hashq-set! *primitive-expand-table*
> +            'equal?
> +            (case-lambda
> +              ((src a b)
> +               ;; Simplify cases where either A or B is constant.
> +               (define (maybe-simplify a b)
> +                 (and (const? a)
> +                      (let ((v (const-exp a)))
> +                        (cond
> +                         ((eq? #f v)
> +                          (make-application src (make-primitive-ref #f 'not)
> +                                            (list b)))

(not v) is not the same as (equal? #f v) when v is #nil.

> +                         ((eq? '() v)
> +                          (make-application src (make-primitive-ref #f 
> 'null?)
> +                                            (list b)))

(null? v) is not the same as (equal? '() v) when v is #nil.

> +                         ((or (eq? #t v)
> +                              (eq? #nil v)
> +                              (symbol? v)
> +                              (and (integer? v)
> +                                   (<= v most-positive-fixnum)
> +                                   (>= v most-negative-fixnum)))
> +                          (make-application src (make-primitive-ref #f 'eq?)
> +                                            (list a b)))

42.0 is an integer in the fixnum range, but (eq? 42.0 v) is not the same
as (equal? 42.0 v).

I have pushed fixes for these.

Also, is there any particular reason you didn't apply the same
optimizations to 'eqv?'?

     Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]