Improve exprOkForSpeculation for classops
This patch fixes #22745 and #15205, which are about GHC's failure to discard unnecessary superclass selections that yield coercions. See GHC.Core.Utils Note [exprOkForSpeculation and type classes] The main changes are: * Write new Note [NON-BOTTOM_DICTS invariant] in GHC.Core, and refer to it * Define new function isTerminatingType, to identify those guaranteed-terminating dictionary types. * exprOkForSpeculation has a new (very simple) case for ClassOpId * ClassOpId has a new field that says if the return type is an unlifted type, or a terminating type. This was surprisingly tricky to get right. In particular note that unlifted types are not terminating types; you can write an expression of unlifted type, that diverges. Not so for dictionaries (or, more precisely, for the dictionaries that GHC constructs). Metric Decrease: LargeRecord
Showing
- compiler/GHC/Core.hs 40 additions, 11 deletionscompiler/GHC/Core.hs
- compiler/GHC/Core/Opt/DmdAnal.hs 1 addition, 1 deletioncompiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/FloatIn.hs 2 additions, 2 deletionscompiler/GHC/Core/Opt/FloatIn.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs 1 addition, 1 deletioncompiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Predicate.hs 5 additions, 3 deletionscompiler/GHC/Core/Predicate.hs
- compiler/GHC/Core/Type.hs 31 additions, 15 deletionscompiler/GHC/Core/Type.hs
- compiler/GHC/Core/Unfold.hs 1 addition, 1 deletioncompiler/GHC/Core/Unfold.hs
- compiler/GHC/Core/Utils.hs 52 additions, 14 deletionscompiler/GHC/Core/Utils.hs
- compiler/GHC/CoreToStg/Prep.hs 7 additions, 3 deletionscompiler/GHC/CoreToStg/Prep.hs
- compiler/GHC/HsToCore/Pmc/Solver.hs 2 additions, 3 deletionscompiler/GHC/HsToCore/Pmc/Solver.hs
- compiler/GHC/Stg/InferTags/Rewrite.hs 2 additions, 3 deletionscompiler/GHC/Stg/InferTags/Rewrite.hs
- compiler/GHC/StgToJS/Expr.hs 1 addition, 2 deletionscompiler/GHC/StgToJS/Expr.hs
- compiler/GHC/Tc/Gen/Splice.hs 1 addition, 1 deletioncompiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Types/Demand.hs 8 additions, 8 deletionscompiler/GHC/Types/Demand.hs
- compiler/GHC/Types/Id.hs 4 additions, 4 deletionscompiler/GHC/Types/Id.hs
- compiler/GHC/Types/Id/Info.hs 7 additions, 2 deletionscompiler/GHC/Types/Id/Info.hs
- compiler/GHC/Types/Id/Make.hs 10 additions, 5 deletionscompiler/GHC/Types/Id/Make.hs
- compiler/GHC/Types/TyThing.hs 1 addition, 1 deletioncompiler/GHC/Types/TyThing.hs
- testsuite/tests/simplCore/should_compile/T15205.hs 8 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T15205.hs
- testsuite/tests/simplCore/should_compile/T15205.stderr 43 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T15205.stderr
Loading
Please register or sign in to comment