]> birchwood-abbey.net Git - mit-scheme.git/commitdiff
Avoid generating (LSL (&U ...) 0) operands where convenient.
authorTaylor R Campbell <campbell+mit-scheme@mumble.net>
Mon, 8 Jun 2020 19:07:21 +0000 (19:07 +0000)
committerTaylor R Campbell <campbell+mit-scheme@mumble.net>
Mon, 8 Jun 2020 19:07:21 +0000 (19:07 +0000)
src/compiler/machines/aarch64/lapgen.scm

index 3d6135d4582f514442f32eca68b5f91ce9508a3d..0609253242caac3364749cbe857bf4e311c49e73 100644 (file)
@@ -315,7 +315,9 @@ USA.
 (define (load-indexed-address target base offset scale)
   (standard-binary target base offset
     (lambda (target base offset)
-      (LAP (ADD X ,target ,base (LSL ,offset ,(scale->shift scale)))))))
+      (if (= scale 1)
+          (LAP (ADD X ,target ,base ,offset))
+          (LAP (ADD X ,target ,base (LSL ,offset ,(scale->shift scale))))))))
 
 (define (load-pc-relative-address target label)
   (LAP (ADR X ,target (@PCR ,label ,regnum:scratch-0))))
@@ -360,13 +362,17 @@ USA.
   (assert (<= 0 imm (bit-mask 64 0)))
   (cond ((find-shift imm)
          => (lambda (shift)
-              (LAP (MOVZ X ,target
-                         (LSL (&U ,(shift-right imm shift)) ,shift)))))
+              (if (zero? shift)
+                  (LAP (MOVZ X ,target (&U ,imm)))
+                  (LAP (MOVZ X ,target
+                             (LSL (&U ,(shift-right imm shift)) ,shift))))))
         ((find-shift (bitwise-andc1 imm #xffffffffffffffff))
          => (lambda (shift)
               (let ((imm (bitwise-andc1 imm #xffffffffffffffff)))
-                (LAP (MOVN X ,target
-                           (LSL (&U ,(shift-right imm shift)) ,shift))))))
+                (if (zero? shift)
+                    (LAP (MOVN X ,target (&U ,imm)))
+                    (LAP (MOVN X ,target
+                               (LSL (&U ,(shift-right imm shift)) ,shift)))))))
         ((logical-imm-u64 imm)
          (LAP (ORR X ,target Z (&U ,imm))))
         ;; XXX try splitting in halves, quarters