racket/typed-racket

Unsound complex `exp` optimization

Ouverte

#969 ouverte le 1 sept. 2020

 (3 commentaires) (0 réaction) (0 personne assignée)Racket (106 forks)github user discovery
good first issueoptimizerunsound

Métriques du dépôt

Stars
 (576 étoiles)
Métriques de merge PR
 (Merge moyen 11j 14h) (1 PR mergée en 30 j)

Description

(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

Guide contributeur