Skip to content
Snippets Groups Projects
Commit 74125b8b authored by rtoy's avatar rtoy
Browse files

Fix potential issue with spurious signals when dividing a complex by a

real because the other parts of the register have random junk in
them.  (There are other places where this is a problem.)
parent 447917e4
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
;;; Scott Fahlman or slisp-group@cs.cmu.edu. ;;; Scott Fahlman or slisp-group@cs.cmu.edu.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/x86/float-sse2.lisp,v 1.4 2008/11/14 20:43:09 rtoy Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/x86/float-sse2.lisp,v 1.5 2009/06/13 03:39:20 rtoy Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -2025,32 +2025,41 @@ ...@@ -2025,32 +2025,41 @@
(complex-*-float double mulpd unpcklpd 4)) (complex-*-float double mulpd unpcklpd 4))
;; Divide a complex by a real ;; Divide a complex by a real
(macrolet (define-vop (complex-double-float-/-double-float)
((complex-/-float (float-type fdiv copy cost) (:args (x :scs (complex-double-reg)) (y :scs (double-reg)))
(let* ((vop-name (symbolicate "COMPLEX-" float-type "-FLOAT-/-" (:results (r :scs (complex-double-reg)))
float-type "-FLOAT")) (:arg-types complex-double-float double-float)
(complex-sc-type (symbolicate "COMPLEX-" float-type "-REG")) (:result-types complex-double-float)
(real-sc-type (symbolicate float-type "-REG")) (:policy :fast-safe)
(c-type (symbolicate "COMPLEX-" float-type "-FLOAT")) (:note "inline complex float arithmetic")
(r-type (symbolicate float-type "-FLOAT"))) (:translate /)
`(define-vop (,vop-name) (:temporary (:sc complex-double-reg) t0)
(:args (x :scs (,complex-sc-type)) (y :scs (,real-sc-type))) (:generator 4
(:results (r :scs (,complex-sc-type))) (inst movaps t0 y) ; t0 = u|y
(:arg-types ,c-type ,r-type) (inst unpcklpd t0 t0) ; t0 = y|y
(:result-types ,c-type) (unless (location= x r)
(:policy :fast-safe) (inst movaps r x)) ; r = xi|xr
(:note "inline complex float arithmetic") (inst divpd r t0)))
(:translate /)
(:temporary (:sc ,complex-sc-type) t0) (define-vop (complex-single-float-/-single-float)
(:generator ,cost (:args (x :scs (complex-single-reg)) (y :scs (single-reg)))
(inst movaps t0 y) ; t0 = u|y or u|u|u|y (:results (r :scs (complex-single-reg)))
,copy ; t0 = y|y or y|y|y|y (:arg-types complex-single-float single-float)
(unless (location= x r) (:result-types complex-single-float)
(inst movaps r x)) (:policy :fast-safe)
(inst ,fdiv r t0)))))) (:note "inline complex float arithmetic")
(complex-/-float single divps (inst shufps t0 t0 0) 4) (:translate /)
(complex-/-float double divpd (inst unpcklpd t0 t0) 4)) (:temporary (:sc complex-single-reg) t0 t1)
(:generator 5
;; The upper parts of x may contain junk and dividing that by y
;; may cause spurious signals. Thus, copy the complex number to
;; the high part.
(inst movaps t0 y) ; t0 = u|u|u|y
(inst shufps t0 t0 0) ; t0 = y|y|y|y
(inst movaps t1 x) ; t1 = u|u|xi|xr
(inst movlhps t1 t1) ; t1 = xi|xr|xi|xr
(inst divps t1 t0)
(inst movaps r t1)))
(define-vop (sse3-*/complex-double-float) (define-vop (sse3-*/complex-double-float)
(:translate *) (:translate *)
...@@ -2128,10 +2137,10 @@ ...@@ -2128,10 +2137,10 @@
;; x = a+b*i = b|a ;; x = a+b*i = b|a
;; y = c+d*i = d|c ;; y = c+d*i = d|c
;; r = a*c-b*d + i*(a*d+b*c) ;; r = a*c-b*d + i*(a*d+b*c)
(inst movaps t1 y) ; t1 = d|c (inst movaps t1 y) ; t1 = u|u|d|c
(inst movaps t2 y) ; t2 = d|c (inst movaps t2 y) ; t2 = u|u|d|c
(inst shufps t1 t1 #b0000) ; t1 = c|c (inst shufps t1 t1 #b00000000) ; t1 = c|c|c|c
(inst shufps t2 t2 #b0101) ; t2 = d|d (inst shufps t2 t2 #b01010101) ; t2 = d|d|d|d
(inst mulps t1 x) ; t1 = b*c|a*c (inst mulps t1 x) ; t1 = b*c|a*c
(inst mulps t2 x) ; t2 = b*d|a*d (inst mulps t2 x) ; t2 = b*d|a*d
(inst shufps t2 t2 1) ; t2 = a*d|b*d (inst shufps t2 t2 1) ; t2 = a*d|b*d
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment