Skip to content
Snippets Groups Projects
Commit 6ab11152 authored by toy's avatar toy
Browse files

Add a deftransform for ABS so that if the arg is known to be non-negative

we don't have to call abs at all.
parent feaa7104
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain. ;;; Carnegie Mellon University, and has been placed in the public domain.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/float-tran.lisp,v 1.96 2004/01/09 04:20:59 toy Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/float-tran.lisp,v 1.97 2004/01/10 05:01:41 toy Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -591,6 +591,15 @@ ...@@ -591,6 +591,15 @@
(coerce (imagpart x) 'double-float)) (coerce (imagpart x) 'double-float))
'single-float)) 'single-float))
(deftransform abs ((x) (real) real)
(let ((x-type (continuation-type x)))
;; If the arg is known to non-negative, we can just return the
;; arg. However, (abs -0.0) is 0.0, so this transform only works
;; on floats that are known not to include negative zero.
(if (csubtypep x-type (specifier-type '(or (rational 0) (float (0d0)) (member 0f0 0d0))))
'x
(give-up))))
(deftransform phase ((x) ((complex double-float)) double-float :when :both) (deftransform phase ((x) ((complex double-float)) double-float :when :both)
'(%atan2 (imagpart x) (realpart x))) '(%atan2 (imagpart x) (realpart x)))
......
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