Opened 12 years ago

Last modified 15 months ago

#2207 new feature request

Load the interface details for GHC.* even without -O

Reported by: simonpj Owned by: Azel
Priority: normal Milestone:
Component: Compiler Version: 6.8.2
Keywords: newcomer Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Neil says: I just tried compiling the following program:

foo = (1 :: Int) == (2 :: Int)

with ghc --ddump-simpl, and no optimisation flags, in GHC 6.6.1

The resultant code is: =
  case GHC.Base.$f2 of tpl_X8 { GHC.Base.:DEq tpl1_B2 tpl2_B3 ->
  tpl1_B2 (GHC.Base.I# 1) (GHC.Base.I# 2)

GHC has introduced dictionaries in this example. In comparison, Yhc and nhc wouldn't introduce dictionaries here, as the type class desugaring knows the type of the item is fixed, and makes a direct call to the appropriate function.

If the desugaring was changed, it would make programs in GHCi run faster, would reduce the size of programs, and would speed up the optimiser, as it would have less to do. I am not sure how much additional work this would require in the simplifier, but if it was minimal, the gains would probably be worth it.

The reason nothing happens is that without -0 GHC does not load the unfoldings for anything from interface files, including GHC.Base. Idea: even without -O, load the unfoldings from GHC.* modules. That would pick up a lot of very fundamental stuff, and might, as Neil says, make compilation faster.

Relatively easy to try. But would need a good nofib run to test the effects. Any takers? I'd point you at what to change.


Attachments (1)

Tick2207.hs (64 bytes) - added by morabbin 7 years ago.
Exhibits problems described in #2207

Download all attachments as: .zip

Change History (19)

comment:1 Changed 12 years ago by igloo

Milestone: 6.10 branch

comment:2 Changed 11 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:3 Changed 11 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:4 Changed 11 years ago by igloo

Milestone: 6.10 branch6.12 branch

comment:5 Changed 10 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:6 Changed 9 years ago by igloo

Priority: normallow

comment:7 Changed 9 years ago by igloo


comment:8 Changed 9 years ago by igloo


comment:9 Changed 8 years ago by igloo


comment:10 Changed 8 years ago by igloo

Priority: lowlowest

comment:11 Changed 7 years ago by igloo


Changed 7 years ago by morabbin

Attachment: Tick2207.hs added

Exhibits problems described in #2207

comment:12 Changed 7 years ago by morabbin

Type of failure: None/Unknown

With ghc 7.6.1 and the attached file:

Orac:~/work/ghc $ ghc -ddump-simpl Tick2207.hs
[1 of 1] Compiling Main             ( Tick2207.hs, Tick2207.o )
... :: GHC.Types.Bool
[GblId] =
    @ GHC.Types.Int
    (GHC.Types.I# 1)
    (GHC.Types.I# 2)

Output is much prettier, but still exhibits OP's issue.

comment:13 Changed 7 years ago by igloo

Milestone: 7.6.2_|_
Priority: lowestnormal

comment:14 Changed 5 years ago by rodlogic

For what is worth, this is in 7.8.3:

❯❯❯ ghc -ddump-simpl a.hs
[1 of 1] Compiling Main             ( a.hs, a.o )

==================== Tidy Core ====================
Result size of Tidy Core = {terms: 13, types: 7, coercions: 0}

Main.main :: GHC.Types.IO ()
[GblId, Str=DmdType]
Main.main =
       @ GHC.Types.Bool
          @ GHC.Types.Int
          (GHC.Types.I# 1)
          (GHC.Types.I# 2)))

:Main.main :: GHC.Types.IO ()
[GblId, Str=DmdType]
:Main.main = GHC.TopHandler.runMainIO @ () Main.main


main = putStrLn $ show foo
foo = (1 :: Int) == (2 :: Int)

comment:15 Changed 21 months ago by bgamari

Keywords: newcomers added

Might be interesting to try.

comment:16 Changed 20 months ago by Azel

I'm willing to have a go at this issue, is anyone already working on it?

comment:17 Changed 19 months ago by Azel

Owner: set to Azel

comment:18 Changed 15 months ago by monoidal

Keywords: newcomer added; newcomers removed
Note: See TracTickets for help on using tickets.