Fix and attempt to improve (if) optimization

This commit is contained in:
Justin Ethier 2016-07-29 19:05:50 -04:00
parent 0fb83a8100
commit 6643eeb083

View file

@ -450,7 +450,9 @@
((if? exp) ((if? exp)
(cond (cond
((not (if->condition exp)) ((not (if->condition exp))
(opt:contract (if->else exp))) (opt:inline-prims (if->else exp) refs)) ;; Always false, so replace with else
((const? (if->condition exp))
(opt:inline-prims (if->then exp) refs)) ;; Always true, replace with then
(else (else
`(if ,(opt:inline-prims (if->condition exp) refs) `(if ,(opt:inline-prims (if->condition exp) refs)
,(opt:inline-prims (if->then exp) refs) ,(opt:inline-prims (if->then exp) refs)