Ticket #1885 (new feature request)

Opened 6 years ago

Last modified 5 months ago

Improve CPR analysis

Reported by: simonpj Owned by: simonpj
Priority: lowest Milestone: 7.6.2
Component: Compiler Version: 6.8.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by simonpj) (diff)

When a function returns a nested data structure, GHC should expose that fact to the caller. This can make a very big difference in inner loops. A good example is the following message (from GHC users  http://www.haskell.org/pipermail/glasgow-haskell-users/2007-November/013454.html).

Compile the attached files thus:

ghc --make Unpacked.hs -O2 -cpp -DPOLY_SAME

and similarly with DPOLY_OTHER. The POLY_OTHER case does a lot more allocation because a key function isn't inlined.

$wa_r1Wb :: GHC.Prim.Addr#
	    -> GHC.Prim.State# GHC.Prim.RealWorld
	    -> (# GHC.Prim.State# GHC.Prim.RealWorld,
		  OtherP.C
		    GHC.Float.Double (OtherP.C GHC.Float.Double 
                                         (OtherP.C GHC.Float.Double ())) #)
[GlobalId]
[Arity 2
 NoCafRefs
 Str: DmdType LL]
$wa_r1Wb =
  \ (ww_s1S5 :: GHC.Prim.Addr#) (w_s1S7 :: GHC.Prim.State# GHC.Prim.RealWorld) ->
    case GHC.Prim.readDoubleOffAddr# @ GHC.Prim.RealWorld ww_s1S5 0 w_s1S7
    of wild2_a1xI { (# s2_a1xK, x_a1xL #) ->
    let {
      ipv_XGd [Just L] :: GHC.Prim.Addr#
      [Str: DmdType]
      ipv_XGd = GHC.Prim.plusAddr# ww_s1S5 8 } in
    case GHC.Prim.readDoubleOffAddr# @ GHC.Prim.RealWorld ipv_XGd 0 s2_a1xK
    of wild21_X1yK { (# s21_X1yN, x1_X1yP #) ->
    case GHC.Prim.readDoubleOffAddr#
	   @ GHC.Prim.RealWorld (GHC.Prim.plusAddr# ipv_XGd 8) 0 s21_X1yN
    of wild22_X1yU { (# s22_X1yX, x2_X1yZ #) ->
    (# s22_X1yX,
       OtherP.C
	 @ GHC.Float.Double
	 @ (OtherP.C GHC.Float.Double (OtherP.C GHC.Float.Double ()))
	 (GHC.Float.D# x_a1xL)
	 (OtherP.C
	    @ GHC.Float.Double
	    @ (OtherP.C GHC.Float.Double ())
	    (GHC.Float.D# x1_X1yP)
	    (OtherP.C @ GHC.Float.Double @ () 
                    (GHC.Float.D# x2_X1yZ) GHC.Base.())) #)
    } } }

Attachments

OtherM.hs Download (0.8 KB) - added by simonpj 6 years ago.
OtherP.hs Download (1.4 KB) - added by simonpj 6 years ago.
Unpacked.hs Download (3.1 KB) - added by simonpj 6 years ago.

Change History

Changed 6 years ago by simonpj

Changed 6 years ago by simonpj

Changed 6 years ago by simonpj

Changed 6 years ago by simonpj

  • description modified (diff)

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 4 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

Changed 3 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

Changed 3 years ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

Changed 3 years ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

Changed 2 years ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

Changed 21 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1

Changed 16 months ago by igloo

  • priority changed from low to lowest
  • milestone changed from 7.4.1 to 7.6.1

Changed 9 months ago by igloo

  • milestone changed from 7.6.1 to 7.6.2

Changed 5 months ago by morabbin

  • failure set to None/Unknown
  • type changed from task to feature request

See also #2289 and #1600.

Note: See TracTickets for help on using tickets.