diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2025-06-16 07:03:38 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2025-06-16 07:03:38 -0700 |
commit | a59d7b7f58e64ec0ced0591b75971c16a2894d48 (patch) | |
tree | 4da449cb385b3151a3054bc4384cf89017eed958 | |
parent | 11f28adf42dd530149e9f424e5e1aeeeff64d198 (diff) | |
download | txr-a59d7b7f58e64ec0ced0591b75971c16a2894d48.tar.gz txr-a59d7b7f58e64ec0ced0591b75971c16a2894d48.tar.bz2 txr-a59d7b7f58e64ec0ced0591b75971c16a2894d48.zip |
compiler: forgotten not/null reductions in if.
* stdlib/compiler.tl (compiler comp-if): Recognize
cases like (if (not <expr>) <then> <else>) and
convert to (if <expr> <else> <then>). Also the
test (true <expr>) is reduced to <expr>.
-rw-r--r-- | stdlib/compiler.tl | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl index 5ff71a96..52c9a908 100644 --- a/stdlib/compiler.tl +++ b/stdlib/compiler.tl @@ -656,6 +656,12 @@ me.(compile oreg env nil)) (((@(member @op %test-funs%) @a @b) . @rest) me.(compile oreg env ^(ift ,op ,a ,b ,*rest))) + (((@(or not null) @arg) @then @else) + me.(comp-if oreg env ^(if ,arg ,else ,then))) + (((@(or not null) @arg) @then) + me.(comp-if oreg env ^(if ,arg nil ,then))) + (((true @arg) . @args) + me.(comp-if oreg env ^(if ,arg ,*args))) ((@test @then @else) (let* ((te-oreg me.(maybe-alloc-treg oreg)) (lelse (gensym "l")) |