Make sure this code is dead
Needs RevisionPublic

Authored by dfeuer on Sep 25 2017, 3:12 PM.

Details

Summary

DO NOT MERGE

dfeuer created this revision.Sep 25 2017, 3:12 PM

Hmmmm.... It seems a case on tagToEnum# is slipping through somehow. That's rather surprising. Is it an optimization level issue? I'll dig into it.

dfeuer planned changes to this revision.Sep 25 2017, 5:01 PM

Ah, it seems that at the end of simplification, there is no case on tagToEnum#, but something is transformed into one in core prep. We start with

readParen
  @ (Const a_s3Au b_s3Av)
  (GHC.Prim.tagToEnum# @ Bool (GHC.Prim.># ww_s3AB 10#))
  (\ (r_a1MS :: String) ->
     go_s3B9
       (Text.ParserCombinators.ReadP.run @ String GHC.Read.lex1 r_a1MS))
  w1_s3Ay

and end up with

case GHC.Prim.># ww_s3C3 10# of sat_s3Cq { __DEFAULT ->
case GHC.Prim.tagToEnum# @ GHC.Types.Bool sat_s3Cq of sat_s3Cr
{ __DEFAULT ->
GHC.Read.readParen
  @ (Consty.Const a_s3Au b_s3Av) sat_s3Cr sat_s3Cu w1_s3C4
}

Ah....

  1. Convert to A-normal form; that is, function arguments are always variables.
    • Use case for strict arguments:

      f E ==> case E of x -> f x

      (where f is strict)
  2. Similarly, convert any unboxed lets into cases.

Is there a nice way to invoke the tagToEnum# and dataToTag# rules when these transformations take place?

bgamari edited edge metadata.Sep 26 2017, 12:01 PM

Is there a nice way to invoke the tagToEnum# and dataToTag# rules when these transformations take place?

This application is problematic,

GHC.Prim.tagToEnum# @ GHC.Types.Bool sat_s3Cq

Since the rule won't fire as the tag argument isn't a literal

dfeuer updated this revision to Diff 14155.Sep 27 2017, 12:33 AM

Much more conservative change

Is there a nice way to invoke the tagToEnum# and dataToTag# rules when these transformations take place?

This application is problematic,

GHC.Prim.tagToEnum# @ GHC.Types.Bool sat_s3Cq

Since the rule won't fire as the tag argument isn't a literal

As I explained in Trac #14283, the relevant rule is actually the caseRules line for tagToEnum#. But
I don't actually see a way to push the tagToEnum# out of the case scrutinee while keeping everything
in ANF, unless we do something weird like

let r = tagToEnum# x
in case r of
  DEFAULT -> f x

which doesn't smell like a good idea.

bgamari requested changes to this revision.Oct 3 2017, 10:36 AM

Bumping out of the review queue.

This revision now requires changes to proceed.Oct 3 2017, 10:36 AM
austin resigned from this revision.Nov 9 2017, 5:39 PM