Simon Peyton Jones pushed to branch wip/spj-try-opt-coercion at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • compiler/GHC/Core/Coercion/Opt.hs
    ... ... @@ -354,10 +354,13 @@ opt_co_refl subst co
    354 354
         -- See Note [Optimising TransCo sequences]
    
    355 355
         go co@(TransCo {}) = gobble gs0 out_cos
    
    356 356
           where
    
    357
    -         out_cos :: [OutCoercion]  -- None of these are TransCos
    
    358
    -         out_cos@(out_co1:_) = get_in co []
    
    359
    -         gs0 = GS (mkReflCo role lk) tm0
    
    360
    -         tm0 = insertTM lk gs0 emptyTM
    
    357
    +         out_cos :: [OutCoercion]  -- None of these are TransCos, and the list non-empty
    
    358
    +         out_cos = get_in co []
    
    359
    +         out_co1 = case out_cos of
    
    360
    +                     (co1:_) -> co1
    
    361
    +                     []      -> pprPanic "gobble" (ppr co)
    
    362
    +         gs0  = GS (mkReflCo role lk) tm0
    
    363
    +         tm0  = insertTM lk gs0 emptyTM
    
    361 364
              lk   = coercionLKind out_co1
    
    362 365
              role = coercionRole out_co1
    
    363 366
     
    
    ... ... @@ -396,18 +399,17 @@ When composing co_i, if coercionRKind( co_i ) is the same as any earlier type in
    396 399
     the chain, we want to discard it and simply revert to the GobbleState of that
    
    397 400
     earlier point.
    
    398 401
     
    
    399
    -So a GobbleState has
    
    402
    +A GobbleState gs_k consists of:
    
    400 403
     
    
    401 404
     * The coercion so far: a coercion equivalent to (co1;co2;cok)
    
    402 405
     * A map from types to all earlier GobbleStates, thus
    
    403 406
         tyR_i :-> gs_i
    
    404
    -  where (INVARIANT) tyR_i is the coercionRKind of gs_i
    
    407
    +  where (INVARIANT) tyR_i is the coercionRKind of co_i stored in gs_i
    
    405 408
     
    
    406 409
     Wrinkles:
    
    407 410
     
    
    408 411
     * Wart: the TypeMap is (currently) multiplicity-sensitive so we might
    
    409 412
       miss a possible TransCo optimisation.
    
    410
    -
    
    411 413
     -}
    
    412 414
     
    
    413 415
     optUnivCo :: UnivCoProvenance -> [Coercion]