From 27898e3aa3c6d7daa784712731aa03a7e6d60b22 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 18 Jan 2022 21:21:03 -0800 Subject: compiler: few more cases of ifq/ifql removal. * optimize.tl (basic-blocks peephole-block): Check for the reversed arguments case of (ifq (d x) (t 0)), and also match ifq. Add a case for two different d registers being compared by ifq or ifql which are not both implicated as load-time regs; that also converts to an unconditional jmp to the else label. Add a case for a register being compared with itself with ifq or ifql, which disappears. --- stdlib/optimize.tl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'stdlib') diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl index 518264f5..5a59a531 100644 --- a/stdlib/optimize.tl +++ b/stdlib/optimize.tl @@ -437,13 +437,22 @@ (pushnew bl.next bb.rescan) (set bb.recalc t) nil) - (@(require ((ifq @(as reg (d @dn)) (t 0) @jlabel) . @nil) + (@(require @(or ((@(or ifq ifql) @(as reg (d @dn)) (t 0) @jlabel) . @nil) + ((@(or ifq ifql) (t 0) @(as reg (d @dn)) @jlabel) . @nil)) (not (memqual reg bb.lt-dregs))) (pushnew bl.next bb.rescan) (set bb.recalc t bl.next nil bl.links (list [bb.hash jlabel])) ^((jmp ,jlabel))) + (@(require ((@(or ifq ifql) @(as reg0 (d @n0)) @(as reg1 (d @n1)) @label) + . @nil) + (neql n0 n1) + (not (and (memqual reg0 bb.lt-dregs) + (memqual reg1 bb.lt-dregs)))) + ^((jmp ,label))) + (((@(or ifq ifql) @reg @reg . @nil) . @nil) + (rest insns)) ;; wasteful move of previously tested value (@(require ((ifq (t @reg) (d @n) @nil) . @nil) (let* ((nxbl bl.next) -- cgit v1.2.3