Skip to content

Unsound complex exp optimization #969

Open
@samth

Description

@samth
(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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions