From 0fbe3181f7630cf1258bf019fce0504728bdb9f8 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sat, 20 Apr 2019 19:48:07 +0000 Subject: [PATCH] Simplify some logic by using dedicated scratch registers or targets. No need to allocate temporaries except when we need more than two or three of them. --- src/compiler/machines/aarch64/rules2.scm | 15 +++------------ src/compiler/machines/aarch64/rules3.scm | 4 ++-- src/compiler/machines/aarch64/rulfix.scm | 11 ++++++----- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/compiler/machines/aarch64/rules2.scm b/src/compiler/machines/aarch64/rules2.scm index 382030ebb..1d555f976 100644 --- a/src/compiler/machines/aarch64/rules2.scm +++ b/src/compiler/machines/aarch64/rules2.scm @@ -80,20 +80,11 @@ USA. (define-rule predicate (PRED-1-ARG INDEX-FIXNUM? (REGISTER (? register))) - (define (operate temp source) + (let* ((source (standard-source! register)) + (temp regnum:scratch-0)) (set-equal-branches!) (LAP (LSR X ,temp ,source (&U ,(- scheme-datum-width 1))) - (CMP X ,temp (&U ,(* 2 type-code:fixnum))))) - ;; This basically is WITH-TEMPORARY-REGISTER-COPY! but without - ;; register references getting in the way. - (reuse-pseudo-register-alias! register 'GENERAL - (lambda (temp) - (need-register! temp) - (operate temp temp)) - (lambda () - (let* ((source (standard-source! register)) - (temp (allocate-temporary-register! 'GENERAL))) - (operate temp source))))) + (CMP X ,temp (&U ,(* 2 type-code:fixnum)))))) (define (zero-test! register) (set-equal-zero-branches! register) diff --git a/src/compiler/machines/aarch64/rules3.scm b/src/compiler/machines/aarch64/rules3.scm index 6756f022e..37ed22954 100644 --- a/src/compiler/machines/aarch64/rules3.scm +++ b/src/compiler/machines/aarch64/rules3.scm @@ -307,8 +307,8 @@ USA. (assert (>= frame-size 2)) (assert (fits-in-unsigned-12? (* 8 frame-size))) ;XXX (assert (= 8 address-units-per-object)) - (let* ((temp1 (allocate-temporary-register! 'GENERAL)) - (temp2 (allocate-temporary-register! 'GENERAL)) + (let* ((temp1 regnum:scratch-0) + (temp2 regnum:scratch-1) (index (allocate-temporary-register! 'GENERAL)) (label (generate-label 'MOVE-LOOP)) ;; Unroll an odd element if there is one; then do an even diff --git a/src/compiler/machines/aarch64/rulfix.scm b/src/compiler/machines/aarch64/rulfix.scm index 8d753b354..b9e30a595 100644 --- a/src/compiler/machines/aarch64/rulfix.scm +++ b/src/compiler/machines/aarch64/rulfix.scm @@ -172,8 +172,9 @@ USA. (if (not overflow?) (LAP (ASR X ,regnum:scratch-0 ,source1 (&U ,scheme-type-width)) (MUL X ,target ,regnum:scratch-0 ,source2)) - (let* ((mask (allocate-temporary-register! 'GENERAL)) - (hi (allocate-temporary-register! 'GENERAL))) + (let* ((mask regnum:scratch-0) + (hi regnum:scratch-1) + (temp (allocate-temporary-register! 'GENERAL))) ;; We're going to test whether the high 64-bits is equal to ;; the -1 or 0 we expect it to be. Overflow if not equal, no ;; overflow if equal. @@ -186,9 +187,9 @@ USA. (CSETM X LT ,mask) (CMP X ,source2 (&U 0)) (CINV X LT ,mask ,mask) - (ASR X ,regnum:scratch-0 ,source1 (&U ,scheme-type-width)) - (SMULH X ,hi ,regnum:scratch-0 ,source2) - (MUL X ,target ,regnum:scratch-0 ,source2) + (ASR X ,temp ,source1 (&U ,scheme-type-width)) + (SMULH X ,hi ,temp ,source2) + (MUL X ,target ,temp ,source2) (CMP X ,mask ,hi)))))) (define-arithmetic-method 'FIXNUM-QUOTIENT fixnum-methods/2-args -- 2.25.1