diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-02-18 08:14:37 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-02-18 08:14:37 -0800 |
commit | a023abcf48661290870b8551520e0f611dbb3a62 (patch) | |
tree | 8beb9dae6e91be96fd2f11ad4ab39eb60a3c368c | |
parent | 35889595b88a07fe68599b5d9a27f8f27af7cb03 (diff) | |
download | txr-a023abcf48661290870b8551520e0f611dbb3a62.tar.gz txr-a023abcf48661290870b8551520e0f611dbb3a62.tar.bz2 txr-a023abcf48661290870b8551520e0f611dbb3a62.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.
-rw-r--r-- | share/txr/stdlib/compiler.tl | 3 |
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) |