* bug#17584: 24.3.91; bug of `=' operator optimization
@ 2014-05-25 3:05 Shigeru Fukaya
2014-05-25 3:09 ` Shigeru Fukaya
0 siblings, 1 reply; 4+ messages in thread
From: Shigeru Fukaya @ 2014-05-25 3:05 UTC (permalink / raw
To: 17584
(byte-optimize-form '(lambda (a b) (= a b 0)))
==> (lambda (a b) (= a b 0))
(byte-optimize-form '(lambda (a b) (= 0 a b)))
==> (lambda (a b) (= a 0))
- (put '= 'byte-optimizer 'byte-optimize-binary-predicate)
+ (put '= 'byte-optimizer 'byte-optimize-predicate)
-- Shigeru
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#17584: 24.3.91; bug of `=' operator optimization
2014-05-25 3:05 bug#17584: 24.3.91; bug of `=' operator optimization Shigeru Fukaya
@ 2014-05-25 3:09 ` Shigeru Fukaya
2014-05-26 12:48 ` Shigeru Fukaya
0 siblings, 1 reply; 4+ messages in thread
From: Shigeru Fukaya @ 2014-05-25 3:09 UTC (permalink / raw
To: 17584
>(byte-optimize-form '(lambda (a b) (= a b 0)))
>==> (lambda (a b) (= a b 0))
>(byte-optimize-form '(lambda (a b) (= 0 a b)))
>==> (lambda (a b) (= a 0))
>
>- (put '= 'byte-optimizer 'byte-optimize-binary-predicate)
>+ (put '= 'byte-optimizer 'byte-optimize-predicate)
byte-optimize-predicate is no good, sorry.
-- Shigeru
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#17584: 24.3.91; bug of `=' operator optimization
2014-05-25 3:09 ` Shigeru Fukaya
@ 2014-05-26 12:48 ` Shigeru Fukaya
2014-05-26 20:54 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Shigeru Fukaya @ 2014-05-26 12:48 UTC (permalink / raw
To: 17584
The following is a code with a little more optimized than
byte-optimize-predicate. It can be used by `<', `<=', `>', `>='.
-- Shigeru
(defun byte-optimize-comparison-predicate (form)
;; (cmp-op arg1 [[arg2]...])
(let (constants
others
(rest (cdr form)))
(while rest
(if (macroexp-const-p (car rest))
(push (car rest) constants)
(push (car rest) others))
(setq rest (cdr rest)))
(if constants
(cond
;; only constants
((null others) (eval form))
;; constants satisfy predicate
((apply (car form) (nreverse constants)) form)
;; always nil
(t `(progn ,@(nreverse others) nil)))
;; no constant
form)))
(byte-optimize-comparison-predicate '(= 0 a b)) ==> (= 0 a b)
(byte-optimize-comparison-predicate '(= 1 1.0 1)) ==> t
(byte-optimize-comparison-predicate '(= 1 a (f) 2)) ==> (progn a (f) nil)
(byte-optimize-comparison-predicate '(<= 1 a (f) 1.0)) ==> (<= 1 a (f) 1.0)
(byte-optimize-comparison-predicate '(< 1 a (f) 1.0)) ==> (progn a (f) nil)
>>(byte-optimize-form '(lambda (a b) (= a b 0)))
>>==> (lambda (a b) (= a b 0))
>>(byte-optimize-form '(lambda (a b) (= 0 a b)))
>>==> (lambda (a b) (= a 0))
>>
>>- (put '= 'byte-optimizer 'byte-optimize-binary-predicate)
>>+ (put '= 'byte-optimizer 'byte-optimize-predicate)
>
>byte-optimize-predicate is no good, sorry.
>
>-- Shigeru
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#17584: 24.3.91; bug of `=' operator optimization
2014-05-26 12:48 ` Shigeru Fukaya
@ 2014-05-26 20:54 ` Stefan Monnier
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2014-05-26 20:54 UTC (permalink / raw
To: Shigeru Fukaya; +Cc: 17584-done
> The following is a code with a little more optimized than
> byte-optimize-predicate. It can be used by `<', `<=', `>', `>='.
Here I also doubt it's worth the trouble: the "multiple arg" version of
those predicates was only added recently so it's not used very often,
and of those cases I doubt many of them would benefit from
your optimization.
So I installed a simpler patch which just fixes the bogus optimization
when there are more than 2 args.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-05-26 20:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-25 3:05 bug#17584: 24.3.91; bug of `=' operator optimization Shigeru Fukaya
2014-05-25 3:09 ` Shigeru Fukaya
2014-05-26 12:48 ` Shigeru Fukaya
2014-05-26 20:54 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).