#5363: optimized profiled version of a program incorectly compiles $!
-------------------------------+--------------------------------------------
    Reporter:  phercek         |       Owner:                                  
        Type:  bug             |      Status:  new                             
    Priority:  normal          |   Component:  Compiler                        
     Version:  7.0.3           |    Keywords:  optimization profiling stricness
    Testcase:                  |   Blockedby:                                  
          Os:  Linux           |    Blocking:                                  
Architecture:  x86_64 (amd64)  |     Failure:  Incorrect result at runtime     
-------------------------------+--------------------------------------------

Comment(by daniel.is.fischer):

 FWIW, I can reproduce the behaviour with 7.0.4 and 6.12.3. With `-auto`
 instead of `-auto-all` there's no stack overflow. I haven't looked deeply
 into the generated core, but what jumps out is that with `-auto-all`, the
 worker for `accumulate` does unnecessary boxing and re-unboxing:
 {{{
 Rec {
 Main.$waccumulate [Occ=LoopBreaker]
   :: [Data.Array.Base.UArray GHC.Types.Int GHC.Types.Int]
      -> GHC.Prim.Int#
      -> GHC.Prim.Int#
 [GblId, Arity=2, Caf=NoCafRefs, Str=DmdType SL]
 Main.$waccumulate =
   \ (w_s1c4 :: [Data.Array.Base.UArray GHC.Types.Int GHC.Types.Int])
     (ww_s1c7 :: GHC.Prim.Int#) ->
     let {
       rv_s1cT :: GHC.Types.Int
       [LclId]
       rv_s1cT = GHC.Types.I# ww_s1c7 } in
     case __scc {accumulate main:Main !}
          case w_s1c4 of _ {
            [] -> rv_s1cT;
            : h_acc t_acd ->
              case h_acc
              of _ { Data.Array.Base.UArray l_aPh u_aPi ds1_aPj ds2_aPk ->
              case ds1_aPj of _ { GHC.Types.I# x_aIT ->
              let {
                y_aPA [Dmd=Just L] :: GHC.Prim.Int#
                [LclId, Str=DmdType]
                y_aPA = GHC.Prim.-# x_aIT 1 } in
              case GHC.Prim.># 0 y_aPA of _ {
                GHC.Bool.False ->
                  letrec {
                    go_s1cX [Occ=LoopBreaker] :: GHC.Prim.Int# ->
 [GHC.Types.Int]
                    [LclId, Arity=1, Str=DmdType L]
                    go_s1cX =
                      \ (x1_aPE :: GHC.Prim.Int#) ->
                        GHC.Types.:
                          @ GHC.Types.Int
                          (GHC.Types.I# (GHC.Prim.indexIntArray# ds2_aPk
 x1_aPE))
                          (case GHC.Prim.==# x1_aPE y_aPA of _ {
                             GHC.Bool.False -> go_s1cX (GHC.Prim.+# x1_aPE
 1);
                             GHC.Bool.True -> GHC.Types.[] @ GHC.Types.Int
                           }); } in
                  case $wsum'_r1eg (go_s1cX 0) 0 of ww1_s1c0 { __DEFAULT ->
                  case Main.$waccumulate t_acd (GHC.Prim.+# ww_s1c7
 ww1_s1c0)
                  of ww2_s1cb { __DEFAULT ->
                  GHC.Types.I# ww2_s1cb
                  }
                  };
                GHC.Bool.True ->
                  case $wsum'_r1eg (GHC.Types.[] @ GHC.Types.Int) 0
                  of ww1_s1c0 { __DEFAULT ->
                  case Main.$waccumulate t_acd (GHC.Prim.+# ww_s1c7
 ww1_s1c0)
                  of ww2_s1cb { __DEFAULT ->
                  GHC.Types.I# ww2_s1cb
                  }
                  }
              }
              }
              }
          }
     of _ { GHC.Types.I# ww2_s1cb ->
     ww2_s1cb
     }
 end Rec }
 }}}

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to