Opened 2 years ago

Last modified 2 years ago

#13867 new bug

Silly definitions remain after SpecConstr

Reported by: simonpj Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.0.1
Keywords: SpecConstr Cc: mpickering
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Consider this

f x xs = let g y = case y of
                  [] -> 0
                  (a:as) -> g as
         g (x:xs)

Compile with -O2 and we get this

f =
  \ (@ t_axv)
    (@ a_axw)
    ($dNum_axx :: Num a_axw)
    (x_amR :: t_axv)
    (xs_amS :: [t_axv]) ->
    let {
      lvl_sxV [Dmd=<S,U>] :: a_axw
      [LclId, Str=DmdType]
      lvl_sxV = fromInteger @ a_axw $dNum_axx Foo.f1 } in
    letrec {
      $sg_syr [Occ=LoopBreaker] :: t_axv -> [t_axv] -> a_axw
      [LclId, Arity=2, Str=DmdType <L,U><L,U>]
      $sg_syr = \ _ [Occ=Dead] (sc1_syq :: [t_axv]) -> g_sxS sc1_syq;
      g_sxS [Occ=LoopBreaker] :: [t_axv] -> a_axw
      [LclId, Arity=1, Str=DmdType <S,1*U>]
      g_sxS =
        \ (y_amU :: [t_axv]) ->
          case y_amU of _ [Occ=Dead] {
            [] -> lvl_sxV;
            : a1_amV as_amW -> g_sxS as_amW
          }; } in
    $sg_syr x_amR xs_amS

Look at that stupid $sg_syr function. It should jolly well be inlined at its only call site. But it isn't because it's a loop breaker? Why is it a loop breaker? Because earlier there was a RULE for g that mentioned $sg.

This is stupid. It's not killing us but it is obviously wrong.

Change History (1)

comment:1 Changed 2 years ago by mpickering

Cc: mpickering added
Keywords: SpecConstr added
Note: See TracTickets for help on using tickets.