summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-06-16 07:28:29 -0700
committerKaz Kylheku <kaz@kylheku.com>2025-06-16 07:28:29 -0700
commitf562f4909bfbe1d2402ba24db5aac7dedadef9ea (patch)
tree2655fe95f018e693b95e479378dc1263970078e3
parenta59d7b7f58e64ec0ced0591b75971c16a2894d48 (diff)
downloadtxr-f562f4909bfbe1d2402ba24db5aac7dedadef9ea.tar.gz
txr-f562f4909bfbe1d2402ba24db5aac7dedadef9ea.tar.bz2
txr-f562f4909bfbe1d2402ba24db5aac7dedadef9ea.zip
compiler: missing wasteful register move elimination.
* stdlib/optimize.tl (basic-blocks do-peephole-block): Adding a case to remove a (mov X X) instruction, moving any register to itself. It's astonishing that this is missing. I'm seeing it happen in tail call cases now because when a tail call passes an unchanging argument, that becomes a self-assignment.
-rw-r--r--stdlib/optimize.tl2
1 files changed, 2 insertions, 0 deletions
diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl
index ac5b3305..c3387a37 100644
--- a/stdlib/optimize.tl
+++ b/stdlib/optimize.tl
@@ -442,6 +442,8 @@
(set bb.recalc t)
(cdr insns))
;; wasteful moves
+ (((mov @reg @reg) . @nil)
+ (cdr insns))
(((mov @reg0 @nil) (mov @reg0 @nil) . @nil)
(cdr insns))
(((mov @reg0 @reg1) (mov @reg1 @reg0) . @rest)