Changes between Version 31 and Version 32 of Commentary/Compiler/NewCodeGenStupidity


Ignore:
Timestamp:
Jan 27, 2012 10:38:35 AM (3 years ago)
Author:
simonmar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/NewCodeGenStupidity

    v31 v32  
    3838 
    3939To avoid it we should generate code that re-uses `cbE` as the destination for the first `if`; that is, we need to load up the registers as if we were returning from the call.  This needs some refactoring in the code generator. 
     40 
     41== Cantankerous Comparisons == 
     42 
     43In `cgrun065` we have 
     44 
     45{{{ 
     46test_sizeofArray :: [Int] 
     47test_sizeofArray = runST $ ST $ \ s# -> go 0# [] s# 
     48  where 
     49    go i acc s# 
     50        | i <# 1000# = case newArray# i 0 s# of 
     51            (# s2#, marr# #) -> go (i +# 1#) ((I# 1#):acc) s2# 
     52        | otherwise = (# s#, acc #) 
     53}}} 
     54 
     55Which compiles to the nice STG code 
     56 
     57{{{ 
     58                let-no-escape { 
     59                    go_sew = 
     60                        sat-only \r srt:SRT:[] [i_seo acc_ser s#1_seq] 
     61                            case <# [i_seo 1000] of wild_seN { 
     62                              GHC.Types.False -> (#,#) [s#1_seq acc_ser]; 
     63                              GHC.Types.True -> 
     64                                  let { sat_seJ = NO_CCS GHC.Integer.Type.S#! [0]; 
     65                                  } in  
     66}}} 
     67 
     68But the comparison is compiled into stupid code: 
     69 
     70{{{ 
     71  cg0: 
     72      // outOfLine should follow: 
     73      _cgm::I64 = %MO_S_Lt_W64(_seo::I64, 1000); 
     74      // emitReturn: Sequel: Assign 
     75      _seN::I64 = I64[GHC.Types.Bool_closure_tbl + (_cgm::I64 << 3)]; 
     76      _cgn::I64 = _seN::I64 & 7; 
     77      if (_cgn::I64 >= 2) goto cgc; else goto cg5; 
     78  cgc: 
     79}}} 
     80 
     81etc. 
     82 
     83We're actually converting to a `Bool` and then doing an algebraic case!  This is a StgCmm issue, not a pipeline issue. 
    4084 
    4185== Instruction reordering ==