From b342d42c002f92f6b34923a1f362563e004d96a0 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 9 Jul 2018 20:36:03 -0700 Subject: compiler: don't hardcode eq in if optimization. * share/txr/stdlib/compiler.tl (copmiler comp-ift): In the case when both values being compared are constant expressions, evaluate the comparison statically using the function, rather than a hard coded eq. Right now, the only funtion handled is in fact eq. --- share/txr/stdlib/compiler.tl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index d1f5c016..6d50296d 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -497,7 +497,7 @@ (set fun [%test-inv% fun]) (swap then else)) (if (and (constantp left) (constantp right)) - me.(compile oreg env (if (eq (eval left) (eval right)) then else)) + me.(compile oreg env (if (call fun (eval left) (eval right)) then else)) (let* ((le-oreg me.(alloc-treg)) (ri-oreg me.(alloc-treg)) (lelse (gensym "l")) -- cgit v1.2.3