summaryrefslogtreecommitdiffstats
path: root/stdlib/compiler.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-06-16 07:03:38 -0700
committerKaz Kylheku <kaz@kylheku.com>2025-06-16 07:03:38 -0700
commita59d7b7f58e64ec0ced0591b75971c16a2894d48 (patch)
tree4da449cb385b3151a3054bc4384cf89017eed958 /stdlib/compiler.tl
parent11f28adf42dd530149e9f424e5e1aeeeff64d198 (diff)
downloadtxr-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>.
Diffstat (limited to 'stdlib/compiler.tl')
-rw-r--r--stdlib/compiler.tl6
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"))