racket/typed-racket

Unsound complex `exp` optimization

Aperta

#969 aperta il 1 set 2020

 (3 commenti) (0 reazioni) (0 assegnatari)Racket (106 fork)github user discovery
good first issueoptimizerunsound

Metriche repository

Star
 (576 stelle)
Metriche merge PR
 (Merge medio 11g 14h) (1 PR mergiata in 30 g)

Descrizione

(exp (log (make-polar 1.7976931348623153e+308 -1.797693134862315e+308)))

produces -8.648665413126592e+306-1.7956115019091953e+308i in Racket but -inf.0-inf.0i after Typed Racket optimization. Optimized code is:

(let-values (((g3)                                        
                    (#%app                                      
                     log                                        
                     (let-values (((g6) '1.7976931348623153e+308))                                                              
                       (let-values (((g7) '-1.797693134862315e+308))                                                            
                         (let-values (((unboxed-real-8)                                                                         
                                       (#%app                   
                                        unsafe-fl*              
                                        g6                      
                                        (#%app unsafe-flcos g7))))                                                              
                           (let-values (((unboxed-imag-9)                                                                       
                                         (#%app                 
                                          unsafe-fl*            
                                          g6                    
                                          (#%app unsafe-flsin g7))))                                                            
                             (#%app                                                                                             
                              unsafe-make-flrectangular         
                              unboxed-real-8                    
                              unboxed-imag-9))))))))            
        (let-values (((unboxed-real-4) (#%app unsafe-flreal-part g3)))                                                          
          (let-values (((unboxed-imag-5) (#%app unsafe-flimag-part g3)))                                                        
            (let-values (((unboxed-scaling-12)                  
                          (#%app unsafe-flexp unboxed-real-4))) 
              (let-values (((unboxed-real-10)                   
                            (#%app                              
                             unsafe-fl*                                                                                         
                             (#%app unsafe-flcos unboxed-imag-5)                                                                
                             unboxed-scaling-12)))              
                (let-values (((unboxed-imag-11)                 
                              (#%app                            
                               unsafe-fl*                                                                                       
                               (#%app unsafe-flsin unboxed-imag-5)                                                              
                               unboxed-scaling-12)))                                                                            
                  (#%app                                        
                   unsafe-make-flrectangular                    
                   unboxed-real-10                              
                   unboxed-imag-11))))))

Disabling the optimization of complex exp might be the right thing.

Originally found here: http://drdr.racket-lang.org/55300/cs/racket/share/pkgs/typed-racket-test/tr-random-testing.rkt

Guida contributor