Opened 9 years ago

Last modified 6 months ago

#2731 new bug

Avoid unnecessary evaluation when unpacking constructors

Reported by: simonpj Owned by:
Priority: lowest Milestone:
Component: Compiler Version: 6.8.3
Keywords: CodeGen 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

Consider

data T a = MkT !a

foo :: T (a,b) -> a
foo (MkT (x,y)) = x

GHC will extract the first component of the MkT, evaluate it, and then extract the first component of the pair. The evaluation step isn't needed, since the component is known to be already-evaluated. UNPACK directives won't work here, because the component is polymorphic.

In the email thread, Tyson posted an example where this extra eval made a significant difference to his inner loop: http://www.haskell.org/pipermail/glasgow-haskell-users/2008-October/015796.html

Simon

Change History (16)

comment:1 Changed 8 years ago by simonmar

Type of failure: Runtime performance bug

comment:2 Changed 7 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:3 Changed 7 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:4 Changed 7 years ago by igloo

Milestone: 7.0.17.0.2

comment:5 Changed 7 years ago by igloo

Milestone: 7.0.27.2.1

comment:6 Changed 6 years ago by igloo

Milestone: 7.2.17.4.1

comment:7 Changed 6 years ago by igloo

Milestone: 7.4.17.6.1
Priority: lowlowest

comment:8 Changed 5 years ago by igloo

Milestone: 7.6.17.6.2

comment:9 Changed 4 years ago by jstolarek

Cc: jan.stolarek@… added

comment:10 Changed 3 years ago by thoughtpolice

Milestone: 7.6.27.10.1

Moving to 7.10.1.

comment:11 Changed 3 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:12 Changed 3 years ago by thoughtpolice

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:13 Changed 2 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

comment:14 Changed 2 years ago by jstolarek

Cc: jan.stolarek@… removed

comment:15 Changed 21 months ago by thomie

Milestone: 8.0.1

comment:16 Changed 6 months ago by simonpj

Keywords: CodeGen added
Note: See TracTickets for help on using tickets.