summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-01-18 21:21:03 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-01-18 21:21:03 -0800
commit27898e3aa3c6d7daa784712731aa03a7e6d60b22 (patch)
treefe9067908c18197d56488c168b15c34eb2dbc07b /stdlib
parent04b4435e2547295017feca83a2ce4d75e38df2b3 (diff)
downloadtxr-27898e3aa3c6d7daa784712731aa03a7e6d60b22.tar.gz
txr-27898e3aa3c6d7daa784712731aa03a7e6d60b22.tar.bz2
txr-27898e3aa3c6d7daa784712731aa03a7e6d60b22.zip
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.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/optimize.tl11
1 files changed, 10 insertions, 1 deletions
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)