Make conjugate correctly optimize.
This commit is contained in:
parent
73c0310369
commit
0d30866d04
|
@ -241,7 +241,7 @@
|
||||||
#:do [(log-unboxing-opt "unboxed unary float complex")]
|
#:do [(log-unboxing-opt "unboxed unary float complex")]
|
||||||
#:with (bindings ...)
|
#:with (bindings ...)
|
||||||
#`(c.bindings ...
|
#`(c.bindings ...
|
||||||
((imag-binding) (unsafe-fl- 0.0 c.imag-binding))))
|
((imag-binding) (unsafe-fl* -1.0 c.imag-binding))))
|
||||||
|
|
||||||
(pattern (#%plain-app op:magnitude^ c:unboxed-float-complex-opt-expr)
|
(pattern (#%plain-app op:magnitude^ c:unboxed-float-complex-opt-expr)
|
||||||
#:with real-binding (generate-temporary "unboxed-real-")
|
#:with real-binding (generate-temporary "unboxed-real-")
|
||||||
|
|
|
@ -33,6 +33,19 @@
|
||||||
(when (equal? r-value tr-value)
|
(when (equal? r-value tr-value)
|
||||||
(fail-check "Known bug no longer exists."))))]))
|
(fail-check "Known bug no longer exists."))))]))
|
||||||
|
|
||||||
|
(define-syntax good-opt
|
||||||
|
(syntax-parser
|
||||||
|
[(_ exp:expr)
|
||||||
|
#`(test-case #,(format "~a" (syntax->datum #'exp))
|
||||||
|
(define r-value (racket-eval #'exp))
|
||||||
|
(define tr-value (tr-eval #'exp))
|
||||||
|
(with-check-info (['r-value r-value]
|
||||||
|
['tr-value tr-value]
|
||||||
|
['location (build-source-location-list (quote-syntax exp))])
|
||||||
|
(when (not (equal? r-value tr-value))
|
||||||
|
(fail-check "Optimizer regression"))))]))
|
||||||
|
|
||||||
|
|
||||||
;; TODO add this as a test
|
;; TODO add this as a test
|
||||||
;; type-before = Single-Flonum-Complex
|
;; type-before = Single-Flonum-Complex
|
||||||
;; type-after = Float-Complex
|
;; type-after = Float-Complex
|
||||||
|
@ -44,12 +57,12 @@
|
||||||
(test-suite "Known bugs"
|
(test-suite "Known bugs"
|
||||||
|
|
||||||
;; Arguments are converted to inexact too early
|
;; Arguments are converted to inexact too early
|
||||||
(bad-opt (* (make-rectangular -inf.0 1) (* 1 1)))
|
(good-opt (* (make-rectangular -inf.0 1) (* 1 1)))
|
||||||
(bad-opt (/ -inf.0-inf.0i 8))
|
(bad-opt (/ -inf.0-inf.0i 8))
|
||||||
(bad-opt (- (* -1 1 +nan.0) 1.0+1.0i))
|
(good-opt (- (* -1 1 +nan.0) 1.0+1.0i))
|
||||||
(bad-opt (- (* (/ 6 11) (/ 1.2345678f0 123456.7f0)) (make-rectangular 0.0 0.3)))
|
(good-opt (- (* (/ 6 11) (/ 1.2345678f0 123456.7f0)) (make-rectangular 0.0 0.3)))
|
||||||
(bad-opt (/ 1.0 0.0+0.0i))
|
(bad-opt (/ 1.0 0.0+0.0i))
|
||||||
(bad-opt (+ 0.0+0.0i (* 1 1 +inf.0)))
|
(good-opt (+ 0.0+0.0i (* 1 1 +inf.0)))
|
||||||
|
|
||||||
;; Unary division has bad underflow
|
;; Unary division has bad underflow
|
||||||
(bad-opt (/ (make-rectangular 1e+100 1e-300)))
|
(bad-opt (/ (make-rectangular 1e+100 1e-300)))
|
||||||
|
@ -75,11 +88,11 @@
|
||||||
(bad-opt (magnitude 3.0e300+4.0e300i))
|
(bad-opt (magnitude 3.0e300+4.0e300i))
|
||||||
|
|
||||||
;; Negation should correctly compute sign of 0.0
|
;; Negation should correctly compute sign of 0.0
|
||||||
(bad-opt (- 0.0+0.0i))
|
(good-opt (- 0.0+0.0i))
|
||||||
(bad-opt (- 0+0i 0.0+0.0i))
|
(bad-opt (- 0+0i 0.0+0.0i))
|
||||||
|
|
||||||
;; Conjugate should correctly compute sign of 0.0
|
;; Conjugate should correctly compute sign of 0.0
|
||||||
(bad-opt (conjugate 0.0+0.0i))))
|
(good-opt (conjugate 0.0+0.0i))))
|
||||||
|
|
||||||
(module+ main
|
(module+ main
|
||||||
(require rackunit/text-ui)
|
(require rackunit/text-ui)
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
#;#;
|
#;#;
|
||||||
#<<END
|
#<<END
|
||||||
TR opt: float-complex-conjugate.rkt 17:0 (+ (conjugate 1.0+2.0i) (conjugate 2.0+4.0i)) -- unboxed binary float complex
|
TR opt: float-complex-conjugate.rkt 20:0 (+ (conjugate 1.0+2.0i) (conjugate 2.0+4.0i)) -- unboxed binary float complex
|
||||||
TR opt: float-complex-conjugate.rkt 17:14 1.0+2.0i -- unboxed literal
|
TR opt: float-complex-conjugate.rkt 20:14 1.0+2.0i -- unboxed literal
|
||||||
TR opt: float-complex-conjugate.rkt 17:24 (conjugate 2.0+4.0i) -- unboxed unary float complex
|
TR opt: float-complex-conjugate.rkt 20:24 (conjugate 2.0+4.0i) -- unboxed unary float complex
|
||||||
TR opt: float-complex-conjugate.rkt 17:3 (conjugate 1.0+2.0i) -- unboxed unary float complex
|
TR opt: float-complex-conjugate.rkt 20:3 (conjugate 1.0+2.0i) -- unboxed unary float complex
|
||||||
TR opt: float-complex-conjugate.rkt 17:35 2.0+4.0i -- unboxed literal
|
TR opt: float-complex-conjugate.rkt 20:35 2.0+4.0i -- unboxed literal
|
||||||
|
TR opt: float-complex-conjugate.rkt 21:0 (conjugate 1.0+0.0i) -- unboxed unary float complex
|
||||||
|
TR opt: float-complex-conjugate.rkt 21:11 1.0+0.0i -- unboxed literal
|
||||||
END
|
END
|
||||||
#<<END
|
#<<END
|
||||||
3.0-6.0i
|
3.0-6.0i
|
||||||
|
1.0-0.0i
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -15,3 +18,4 @@ END
|
||||||
#:optimize
|
#:optimize
|
||||||
|
|
||||||
(+ (conjugate 1.0+2.0i) (conjugate 2.0+4.0i))
|
(+ (conjugate 1.0+2.0i) (conjugate 2.0+4.0i))
|
||||||
|
(conjugate 1.0+0.0i)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user