(frob >)
(frob =))
+;; Convert (/ x n) to (* x (/ n)) when x is a float and n is a power
+;; of two, because (/ n) can be reprsented exactly.
+(deftransform / ((x y) (float float) * :when :both)
+ (unless (constant-continuation-p y)
+ (give-up))
+ (let ((val (continuation-value y)))
+ (multiple-value-bind (frac exp sign)
+ (decode-float val)
+ (unless (= frac 0.5)
+ (give-up))
+ `(* x (float (/ ,val) x)))))
+
+;; Convert 2*x to x+x.
+(deftransform * ((x y) (float real) * :when :both)
+ (unless (constant-continuation-p y)
+ (give-up))
+ (let ((val (continuation-value y)))
+ (unless (= val 2)
+ (give-up))
+ '(+ x x)))
+
+
\f
;;;; Irrational transforms: