[GHC] #12916: GHC 8.0.1 vs GHC HEAD (8.1.20161202) doesn't do inlining and unboxing very well

GHC ghc-devs at haskell.org
Fri Dec 2 17:17:53 UTC 2016


#12916: GHC 8.0.1 vs GHC HEAD (8.1.20161202) doesn't do inlining and unboxing very
well
-------------------------------------+-------------------------------------
        Reporter:  alexbiehl         |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Well, something must be different...

 {{{
 ghc4/inplace/bin/ghc-stage2 Bug.hs -O2 -threaded -rtsopts -ddump-simpl
 -dsuppress-idinfo  -dsuppress-coercions -dsuppress-type-applications
 -dsuppress-uniques -dsuppress-module-prefixes -fforce-recomp
 [1 of 1] Compiling X                ( Bug.hs, Bug.o )
 ...
 -- RHS size: {terms: 2, types: 2, coercions: 0}
 empResult2 :: Either Error Int
 empResult2 = Left Error

 -- RHS size: {terms: 175, types: 184, coercions: 4}
 $wempResult
   :: IO (Maybe (Vector ColValue))
      -> State# RealWorld -> (# State# RealWorld, Either Error Int #)
 $wempResult =
   \ (ww :: IO (Maybe (Vector ColValue))) (w :: State# RealWorld) ->
     letrec {
       $sloop
         :: State# RealWorld
            -> Int# -> (# State# RealWorld, Either Error Int #)
       $sloop =
         \ (sc :: State# RealWorld) (sc1 :: Int#) ->
           case (ww `cast` ...) sc of { (# ipv, ipv1 #) ->
           case ipv1 of {
             Nothing -> (# ipv, Right (I# sc1) #);
             Just a ->
               case length $fVectorVectora a of { I# y ->
               case y of {
                 __DEFAULT -> (# ipv, empResult2 #);
                 4# ->
                   case a of { Vector dt dt1 dt2 ->
                   let {
                     $wsucc_
                       :: Int#
                          -> State# RealWorld -> (# State# RealWorld,
 Either Error Int #)
                     $wsucc_ =
                       \ (ww1 :: Int#) (w1 :: State# RealWorld) ->
                         let {
                           $wsucc_1
                             :: Int#
                                -> State# RealWorld -> (# State# RealWorld,
 Either Error Int #)
                           $wsucc_1 =
                             \ (ww2 :: Int#) (w2 :: State# RealWorld) ->
                               case indexArray# dt2 (+# dt ww2) of { (#
 ipv2 #) ->
                               case ipv2 of {
                                 __DEFAULT -> (# w2, empResult2 #);
                                 CV_Int8 dt4 ->
                                   case indexArray# dt2 (+# dt (+# ww2 1#))
 of { (# ipv3 #) ->
                                   case ipv3 of {
                                     __DEFAULT -> (# w2, empResult2 #);
                                     CV_Text t -> $sloop w2 (+# sc1 1#)
                                   }
                                   };
                                 CV_Int16 dt4 ->
                                   case indexArray# dt2 (+# dt (+# ww2 1#))
 of { (# ipv3 #) ->
                                   case ipv3 of {
                                     __DEFAULT -> (# w2, empResult2 #);
                                     CV_Text t -> $sloop w2 (+# sc1 1#)
                                   }
                                   };
                                 CV_Int32 dt4 ->
                                   case indexArray# dt2 (+# dt (+# ww2 1#))
 of { (# ipv3 #) ->
                                   case ipv3 of {
                                     __DEFAULT -> (# w2, empResult2 #);
                                     CV_Text t -> $sloop w2 (+# sc1 1#)
                                   }
                                   }
                               }
                               } } in
                         case indexArray# dt2 (+# dt ww1) of { (# ipv2 #)
 ->
                         case ipv2 of {
                           __DEFAULT -> (# w1, empResult2 #);
                           CV_Int8 dt4 -> $wsucc_1 (+# ww1 1#) w1;
                           CV_Int16 dt4 -> $wsucc_1 (+# ww1 1#) w1;
                           CV_Int32 dt4 -> $wsucc_1 (+# ww1 1#) w1
                         }
                         } } in
                   case indexArray# dt2 dt of { (# ipv2 #) ->
                   case ipv2 of {
                     __DEFAULT -> (# ipv, empResult2 #);
                     CV_Int8 dt4 -> $wsucc_ 1# ipv;
                     CV_Int16 dt4 -> $wsucc_ 1# ipv;
                     CV_Int32 dt4 -> $wsucc_ 1# ipv
                   }
                   }
                   }
               }
               }
           }
           }; } in
     $sloop w 0#

 -- RHS size: {terms: 8, types: 16, coercions: 0}
 empResult1
   :: InputStream (Vector ColValue)
      -> State# RealWorld -> (# State# RealWorld, Either Error Int #)
 empResult1 =
   \ (w :: InputStream (Vector ColValue)) (w1 :: State# RealWorld) ->
     case w of { InputStream ww1 ww2 -> $wempResult ww1 w1 }

 -- RHS size: {terms: 1, types: 0, coercions: 13}
 empResult :: Result Int
 empResult = empResult1 `cast` ...
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12916#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list