Re: [GHC] #7295: bad code for Double literals

2012-10-22 Thread GHC
#7295: bad code for Double literals
-+--
Reporter:  jwlato|   Owner:  igloo   
Type:  bug   |  Status:  patch   
Priority:  high  |   Milestone:  7.8.1   
   Component:  Compiler  | Version:  7.6.1   
Keywords:|  Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  | Failure:  None/Unknown
  Difficulty:  Unknown   |Testcase:  
   Blockedby:|Blocking:  
 Related:|  
-+--

Comment(by jwlato@…):

 commit 771d376bb6d2ab524741c6d0732718ac2613d2a1
 {{{
 Author: John Lato jwl...@gmail.com
 Date:   Mon Oct 8 12:54:55 2012 +0800

 add GHC.Float.rationalToFloat, rationalToDouble (fixes #7295)

 Adds better support for constant folding of Float/Double literals.
   - add rationalToFloat, rationalToDouble with associated Name/Id's in
 PrelNames.
   - add a matching rule in PrelRules for rationalTo* functions.

  compiler/prelude/PrelNames.lhs |   13 +
  compiler/prelude/PrelRules.lhs |   29 +
  2 files changed, 42 insertions(+), 0 deletions(-)
 }}}

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7295#comment:7
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #7295: bad code for Double literals

2012-10-22 Thread GHC
#7295: bad code for Double literals
---+
  Reporter:  jwlato|  Owner:  igloo   
  Type:  bug   | Status:  closed  
  Priority:  high  |  Milestone:  7.8.1   
 Component:  Compiler  |Version:  7.6.1   
Resolution:  fixed |   Keywords:  
Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown  | Difficulty:  Unknown 
  Testcase:|  Blockedby:  
  Blocking:|Related:  
---+
Changes (by igloo):

  * status:  patch = closed
  * resolution:  = fixed


Comment:

 Thanks for the patches; I've applied them.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7295#comment:8
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #7295: bad code for Double literals

2012-10-21 Thread GHC
#7295: bad code for Double literals
-+--
Reporter:  jwlato|   Owner:  igloo   
Type:  bug   |  Status:  patch   
Priority:  high  |   Milestone:  7.8.1   
   Component:  Compiler  | Version:  7.6.1   
Keywords:|  Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  | Failure:  None/Unknown
  Difficulty:  Unknown   |Testcase:  
   Blockedby:|Blocking:  
 Related:|  
-+--
Changes (by conrad):

 * cc: conrad@… (added)


-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7295#comment:6
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #7295: bad code for Double literals

2012-10-19 Thread GHC
#7295: bad code for Double literals
-+--
Reporter:  jwlato|   Owner:  igloo   
Type:  bug   |  Status:  patch   
Priority:  high  |   Milestone:  7.8.1   
   Component:  Compiler  | Version:  7.6.1   
Keywords:|  Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  | Failure:  None/Unknown
  Difficulty:  Unknown   |Testcase:  
   Blockedby:|Blocking:  
 Related:|  
-+--
Changes (by erikd):

 * cc: mle+hs@… (added)


-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7295#comment:5
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #7295: bad code for Double literals

2012-10-08 Thread GHC
#7295: bad code for Double literals
-+--
Reporter:  jwlato|   Owner:  igloo   
Type:  bug   |  Status:  patch   
Priority:  high  |   Milestone:  7.8.1   
   Component:  Compiler  | Version:  7.6.1   
Keywords:|  Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  | Failure:  None/Unknown
  Difficulty:  Unknown   |Testcase:  
   Blockedby:|Blocking:  
 Related:|  
-+--

Comment(by simonpj):

 Thanks!  That's part of it, but you need a corresponding change to the
 library or nothing will happen.  Ian owns the ticket now, and your work
 will make it easier.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7295#comment:4
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #7295: bad code for Double literals

2012-10-07 Thread GHC
#7295: bad code for Double literals
-+--
Reporter:  jwlato|   Owner:  igloo   
Type:  bug   |  Status:  patch   
Priority:  high  |   Milestone:  7.8.1   
   Component:  Compiler  | Version:  7.6.1   
Keywords:|  Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  | Failure:  None/Unknown
  Difficulty:  Unknown   |Testcase:  
   Blockedby:|Blocking:  
 Related:|  
-+--
Changes (by jwlato):

  * status:  new = patch


Comment:

 I put together a patch along the lines of SPJ's suggestion.  It seems to
 work for this small test and some other code, but I was unable to validate
 it (the validation build doesn't work for me with or without this patch).

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7295#comment:3
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #7295: bad code for Double literals

2012-10-04 Thread GHC
#7295: bad code for Double literals
-+--
Reporter:  jwlato|   Owner:  igloo   
Type:  bug   |  Status:  new 
Priority:  normal|   Milestone:  
   Component:  Compiler  | Version:  7.6.1   
Keywords:|  Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  | Failure:  None/Unknown
  Difficulty:  Unknown   |Testcase:  
   Blockedby:|Blocking:  
 Related:|  
-+--
Changes (by simonpj):

  * owner:  = igloo
  * difficulty:  = Unknown


Comment:

 Good point. Here's what is happening.
  * In `map (* (-0.5)) xs :: [Double]`, the typechecker and/or desugarer
 can see a totally mono-typed use of the literal `0.5` at `Double` and so
 genreates exactly that literal.
  * But in your main example, you define a polymorphic function `f`, whose
 type is
 {{{
 f :: Fractional a = a - a
 }}}
  Sure, `f` has only one call site but the typechecker/desugarer don't know
 that, so they generate `fromRational d (negate d (1 % 2))`, where `d` is
 the fractional dictionary.

 So, good as the typechecker/desugarer short-cut is for literals, your
 example points out that we should do better constant folding for literals
 that start life overloaded, but become specialised. This will also happen
 when we have a top-level overloaded function that gets specialised.

 My solution.  In `GHC.Float` we see
 {{{
 instance Fractional Float where
   fromRational = blah blah blah
 }}}
 Instead we want
 {{{
 instance Fractioal Float where
   {-# INLINE fromRational #-}
   fromRational (a :% b) = rationalToFloat a b

 rationalToFloat :: Integer - Integer - Float
 {-# NOINLINE [1] rationalToFloat
 rationalToFloat = blah blah blah   -- As before
 }}}
 AND we want a constant-folding rule in `PrelRules` for `rationalToFloat`
 that spots two `Integer`-literal arguments and produces the right float;
 just like `TcHsSyn.shortCutLit` does.

 Same for `fromRational` at `Double`.

 We already have similar mechanisms for `fromInteger`, so I think that's
 all right.

 Simon

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7295#comment:1
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #7295: bad code for Double literals

2012-10-04 Thread GHC
#7295: bad code for Double literals
-+--
Reporter:  jwlato|   Owner:  igloo   
Type:  bug   |  Status:  new 
Priority:  high  |   Milestone:  7.8.1   
   Component:  Compiler  | Version:  7.6.1   
Keywords:|  Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  | Failure:  None/Unknown
  Difficulty:  Unknown   |Testcase:  
   Blockedby:|Blocking:  
 Related:|  
-+--
Changes (by simonpj):

  * priority:  normal = high
  * milestone:  = 7.8.1


-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7295#comment:2
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs