Opened 9 years ago

Closed 9 years ago

#4431 closed bug (fixed)

SpecConstr doesn't specialise

Reported by: rl Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Compile this with -O2 -fno-spec-constr-count:

foo :: Int -> Int -> Bool
foo n x = loop 0 False (Just x)
  where
    loop i b x | i > n = b
    loop i False x = loop (i+1) True x
    loop i True (Just x) = loop (i+1) False Nothing
    loop i True Nothing  = loop (i+1) True (Just x)

SpecConstr produces a loop of type Maybe Int -> Int# -> Bool, i.e., it doesn't specialise for the Maybe argument for some reason.

Change History (2)

comment:1 Changed 9 years ago by simonpj

Status: newmerge

Good point! Fixed by

Mon Oct 25 07:31:08 PDT 2010  simonpj@microsoft.com
  * For a non-recursive let, make sure we extend the value environment
  
  This has been wrong for a long time.  Fixes Trac #4431.

    M ./compiler/specialise/SpecConstr.lhs -4 +8

Please merge.

Simon

comment:2 Changed 9 years ago by igloo

Resolution: fixed
Status: mergeclosed

Merged.

Note: See TracTickets for help on using tickets.