summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-02-18 08:14:37 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-02-18 08:14:37 -0800
commitf2441b0b93c9ed2c4d0ca46c89f0677fc60a5a85 (patch)
tree8beb9dae6e91be96fd2f11ad4ab39eb60a3c368c /share
parentd460fe76189c477d2fca48477fc26612148c469f (diff)
downloadtxr-f2441b0b93c9ed2c4d0ca46c89f0677fc60a5a85.tar.gz
txr-f2441b0b93c9ed2c4d0ca46c89f0677fc60a5a85.tar.bz2
txr-f2441b0b93c9ed2c4d0ca46c89f0677fc60a5a85.zip
compiler: reduce (if (not (eq ...) ...)).
* share/txr/stdlib/compiler.tl (compiler comp-if): Recognize the pattern (if (not (eq ...) ..), and convert to (if (neq ...) ...) and likewise for eql and equal. This is fed back to comp-if, whereby it may be further reduced.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/compiler.tl3
1 files changed, 3 insertions, 0 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl
index cd602573..4b71b572 100644
--- a/share/txr/stdlib/compiler.tl
+++ b/share/txr/stdlib/compiler.tl
@@ -535,6 +535,9 @@
(if pos 'eq 'neq)
(if pos'eql 'neql))))
me.(compile oreg env ^(if (,cf ,a ,b) ,*rest))))
+ (((not (@(and @(or eq eql equal) @op) . @eargs)) . @args)
+ (let ((nop (caseq op (eq 'neq) (eql 'neql) (equal 'nequal))))
+ me.(comp-if oreg env ^(if (,nop ,*eargs) ,*args))))
((@(constantp @test) @then @else)
me.(compile oreg env (if (eval test) then else)))
((@(constantp @test) @then)