Opened 4 years ago

Closed 4 years ago

#11064 closed bug (fixed)

Call Arity has the trivial application case wrong

Reported by: nomeata Owned by: nomeata
Priority: normal Milestone: 7.10.3
Component: Compiler Version: 7.10.2
Keywords: 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:

Description

In e x, the result of x is not shared in contrast to e (f x), where CorePrep will turn it into let y = f x in e x. So in

  let f = ...
  in e (f x)

we know that f is called at most once, but in

  let f = ...
  in e f

we do not know that.

Previously Call Arity would assume that in e x, x is evaluated at most once. This rarely would make a difference (the argument x is analized with an incoming arity of 0, so no eta-expansion would be done anyways), but of course this should still be fixed.

I just validated a patch and will push shortly.

Change History (5)

comment:1 Changed 4 years ago by Joachim Breitner <mail@…>

In a58eeb7/ghc:

Call Arity: In "e x", the result of "x" is not shared

in contrast to "e (f x)", where CorePrep will turn it into "let y = f x
in e x". So in
  let f = ...
  in e (f x)
we know that f is called at most once, but in
  let f = ...
  in e f
we do not know that.

Previously Call Arity would assume that in "e x", "x" is evaluated at
most once. This rarely would make a difference (the argument "x" is
analized with an incoming arity of 0, so no eta-expansion would be done
anyways), but of course this should still be fixed.

This fixes #11064.

Note the corresponding code dmdTransformThunkDmd in DmdAnal.

comment:2 Changed 4 years ago by nomeata

Status: newmerge

Pushed to master. I’d like to see this in 7.10.3, if possible.

comment:3 Changed 4 years ago by nomeata

Milestone: 7.10.3

comment:4 Changed 4 years ago by bgamari

Is there some way we could formulate a test for this?

comment:5 Changed 4 years ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.