From e9b27793ef9f51f85d4e211813916d01582d7e34 Mon Sep 17 00:00:00 2001
From: Chris Hanson <org/chris-hanson/cph>
Date: Thu, 28 May 1987 17:59:24 +0000
Subject: [PATCH] Do not cache assignments from a machine register to a pseudo
 register.

---
 v7/src/compiler/rtlopt/rcse1.scm | 99 ++++++++++++++++----------------
 1 file changed, 50 insertions(+), 49 deletions(-)

diff --git a/v7/src/compiler/rtlopt/rcse1.scm b/v7/src/compiler/rtlopt/rcse1.scm
index d9c73be0a..9bb67049f 100644
--- a/v7/src/compiler/rtlopt/rcse1.scm
+++ b/v7/src/compiler/rtlopt/rcse1.scm
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/rtlopt/rcse1.scm,v 1.104 1987/05/18 23:24:33 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/rtlopt/rcse1.scm,v 1.105 1987/05/28 17:59:24 cph Exp $
 
 Copyright (c) 1987 Massachusetts Institute of Technology
 
@@ -94,54 +94,55 @@ MIT in each case. |#
 		       statement
     (lambda (volatile? insert-source!)
       (let ((address (rtl:assign-address statement)))
-	(cond ((rtl:register? address)
-	       (register-expression-invalidate! address)
-	       (if (and (not volatile?)
-			;; This is a kludge.  If the address is the
-			;; frame pointer, then the source is the stack
-			;; pointer.  If this is not done then some of
-			;; the references to stack locations use the
-			;; stack pointer instead of the frame pointer.
-			;; This is not a bug but I want the stack
-			;; addressing to be uniform for now.  -- cph
-			(not (interpreter-frame-pointer? address)))
-		   (insert-register-destination! address (insert-source!))))
-	      (else
-	       (full-expression-hash address
-		 (lambda (hash volatile?* in-memory?*)
-		   (let ((memory-invalidate!
-			  (cond ((and (memq (rtl:expression-type address)
-					    '(PRE-INCREMENT POST-INCREMENT))
-				      (or (interpreter-stack-pointer?
-					   (rtl:address-register address))
-					  (interpreter-free-pointer?
-					   (rtl:address-register address))))
-				 (lambda ()
-				   (register-expression-invalidate!
-				    (rtl:address-register address))))
-				((expression-address-varies? address)
-				 (lambda ()
-				   (hash-table-delete-class!
-				    element-in-memory?)))
-				(else
-				 (lambda ()
-				   (hash-table-delete!
-				    hash
-				    (hash-table-lookup hash address))
-				   (hash-table-delete-class!
-				    element-address-varies?))))))
-		     (cond (volatile?* (memory-invalidate!))
-			   ((not volatile?)
-			    (let ((address
-				   (find-cheapest-expression address hash
-							     false)))
-			      (let ((element (insert-source!)))
-				(memory-invalidate!)
-				(insert-memory-destination!
-				 address
-				 element
-				 (modulo (+ (symbol-hash 'ASSIGN) hash)
-					 n-buckets)))))))))))))))
+	(if (rtl:register? address)
+	    (begin 
+	      (register-expression-invalidate! address)
+	      (if (and (not volatile?)
+		       (not (rtl:machine-register-expression?
+			     (rtl:assign-expression statement)))
+		       ;; This is a kludge.  If the address is the
+		       ;; frame pointer, then the source is the stack
+		       ;; pointer.  If this is not done then some of
+		       ;; the references to stack locations use the
+		       ;; stack pointer instead of the frame pointer.
+		       ;; This is not a bug but I want the stack
+		       ;; addressing to be uniform for now.  -- cph
+		       (not (interpreter-frame-pointer? address)))
+		  (insert-register-destination! address (insert-source!))))
+	    (full-expression-hash address
+	      (lambda (hash volatile?* in-memory?*)
+		(let ((memory-invalidate!
+		       (cond ((and (memq (rtl:expression-type address)
+					 '(PRE-INCREMENT POST-INCREMENT))
+				   (or (interpreter-stack-pointer?
+					(rtl:address-register address))
+				       (interpreter-free-pointer?
+					(rtl:address-register address))))
+			      (lambda ()
+				(register-expression-invalidate!
+				 (rtl:address-register address))))
+			     ((expression-address-varies? address)
+			      (lambda ()
+				(hash-table-delete-class! element-in-memory?)))
+			     (else
+			      (lambda ()
+				(hash-table-delete!
+				 hash
+				 (hash-table-lookup hash address))
+				(hash-table-delete-class!
+				 element-address-varies?))))))
+		  (cond (volatile?* (memory-invalidate!))
+			((not volatile?)
+			 (let ((address
+				(find-cheapest-expression address hash
+							  false)))
+			   (let ((element (insert-source!)))
+			     (memory-invalidate!)
+			     (insert-memory-destination!
+			      address
+			      element
+			      (modulo (+ (symbol-hash 'ASSIGN) hash)
+				      n-buckets))))))))))))))
 
 (define (trivial-action volatile? insert-source!)
   (if (not volatile?)
-- 
2.25.1