Skip to content
  • niteria's avatar
    Make callToPats deterministic in SpecConstr · 5b2b7e33
    niteria authored
    This fixes a non-determinism bug where where depending on the
    order of uniques allocated, the specialized workers would have different
    order of arguments.
    
    Compare:
    
    ```
      $s$wgo_s1CN :: Int# -> Int -> Int#
      [LclId, Arity=2, Str=DmdType <L,U><L,U>]
      $s$wgo_s1CN =
        \ (sc_s1CI :: Int#) (sc_s1CJ :: Int) ->
          case tagToEnum# @ Bool (<=# sc_s1CI 0#) of _ [Occ=Dead] {
            False ->
              $wgo_s1BU (Just @ Int (I# (-# sc_s1CI 1#))) (Just @ Int sc_s1CJ);
            True -> 0#
          }
    ```
    
    vs
    
    ```
      $s$wgo_s18mTj :: Int -> Int# -> Int#
      [LclId, Arity=2, Str=DmdType <L,U><L,U>]
      $s$wgo_s18mTj =
        \ (sc_s18mTn :: Int) (sc_s18mTo :: Int#) ->
          case tagToEnum# @ Bool (<=# sc_s18mTo 0#) of _ [Occ=Dead] {
            False ->
              $wgo_s18mUc
                (Just @ Int (I# (-# sc_s18mTo 1#))) (Just @ Int sc_s18mTn);
            True -> 0#
          }
    ```
    
    Test Plan:
    I've added a new testcase
    ./validate
    
    Reviewers: simonmar, simonpj, austin, goldfire, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1508
    
    GHC Trac Issues: #4012
    5b2b7e33