[GHC] #15570: Core transformations generate bad indexCharOffAddr# call

GHC ghc-devs at haskell.org
Tue Aug 28 16:33:57 UTC 2018


#15570: Core transformations generate bad indexCharOffAddr# call
-------------------------------------+-------------------------------------
        Reporter:  alpmestan         |                Owner:  alpmestan
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.5
      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 simonpj):

 This is all very mysterious.  What I get from HEAD (for `f`) is this:
 {{{
 Rec {
 -- RHS size: {terms: 33, types: 19, coercions: 0, joins: 0/0}
 Bug.$wgo [InlPrag=NOUSERINLINE[2], Occ=LoopBreaker]
   :: Int# -> [Char] -> (# Char, [Char] #)
 [GblId, Arity=2, Caf=NoCafRefs, Str=<S,U><L,U>, Unf=OtherCon []]
 Bug.$wgo
   = \ (ww_s2QZ :: Int#) (w_s2QW :: [Char]) ->
       case quotRemInt# ww_s2QZ 62# of { (# ipv_a2OJ, ipv1_a2OK #) ->
       case indexCharOffAddr# chars62_r2NR ipv1_a2OK of wild_X4
       { __DEFAULT ->
       case <# ww_s2QZ 62# of {
         __DEFAULT ->
           Bug.$wgo
             ipv_a2OJ (GHC.Types.: @ Char (GHC.Types.C# wild_X4) w_s2QW);
         1# ->
           case indexCharOffAddr# chars62_r2NR ww_s2QZ of wild1_XM
           { __DEFAULT ->
           (# GHC.Types.C# wild1_XM, w_s2QW #)
           }
       }
       }
       }
 end Rec }

 -- RHS size: {terms: 13, types: 15, coercions: 0, joins: 0/0}
 Bug.f_go [InlPrag=NOUSERINLINE[2]] :: Int -> [Char] -> [Char]
 [GblId,
  Arity=2,
  Caf=NoCafRefs,
  Str=<S(S),1*U(U)><L,U>m2,
  Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
          WorkFree=True, Expandable=True,
          Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False)
          Tmpl= \ (w_s2QV [Occ=Once!] :: Int)
                  (w1_s2QW [Occ=Once] :: [Char]) ->
                  case w_s2QV of { I# ww1_s2QZ [Occ=Once] ->
                  case Bug.$wgo ww1_s2QZ w1_s2QW of
                  { (# ww3_s2R5 [Occ=Once], ww4_s2R6 [Occ=Once] #) ->
                  GHC.Types.: @ Char ww3_s2R5 ww4_s2R6
                  }
                  }}]
 Bug.f_go
   = \ (w_s2QV :: Int) (w1_s2QW :: [Char]) ->
       case w_s2QV of { I# ww1_s2QZ ->
       case Bug.$wgo ww1_s2QZ w1_s2QW of { (# ww3_s2R5, ww4_s2R6 #) ->
       GHC.Types.: @ Char ww3_s2R5 ww4_s2R6
       }
       }

 -- RHS size: {terms: 12, types: 14, coercions: 0, joins: 0/0}
 f :: Int -> String
 [GblId,
  Arity=1,
  Caf=NoCafRefs,
  Str=<S(S),1*U(U)>m2,
  Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
          WorkFree=True, Expandable=True,
          Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False)
          Tmpl= \ (n__aXh [Occ=Once] :: Int) ->
                  Bug.f_go n__aXh (GHC.Types.[] @ Char)}]
 f = \ (n__aXh :: Int) ->
       case n__aXh of { I# ww1_s2QZ ->
       case Bug.$wgo ww1_s2QZ (GHC.Types.[] @ Char) of
       { (# ww3_s2R5, ww4_s2R6 #) ->
       GHC.Types.: @ Char ww3_s2R5 ww4_s2R6
       }
       }
 }}}
 which looks very plausible.

 You are getting something quite different with your Hadrian build.  Can
 you give precise repro instructions?  (Including `build.mk` etc.)

 I'm very puzzled about this mysterious case of `GHC.Real.even3`. Where on
 earth does that come from?  And if it is equal to `-1` why doesn't the
 case get eliminated?

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


More information about the ghc-tickets mailing list