Opened 7 years ago

Closed 7 years ago

#7219 closed bug (fixed)

Reinstate constant propagation in some form

Reported by: simonmar Owned by:
Priority: highest Milestone: 7.8.1
Component: Compiler Version: 7.7
Keywords: Cc: tibbe
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

The new codegen doesn't have a constant propagation pass. This used to be done by the mini-inliner which was ad-hoc at best; instead of the mini-inliner we now have CmmSink which is much less ad-hoc but doesn't do constant folding or propagation.

This is a regression that will affect performance of things like copyArray#, so we should fix it before the release.

Change History (4)

comment:1 Changed 7 years ago by marlowsd@…

commit a7c0387d20c1c9994d1100b14fbb8fb4e28a259e

Author: Simon Marlow <marlowsd@gmail.com>
Date:   Wed Oct 3 09:30:56 2012 +0100

    Produce new-style Cmm from the Cmm parser
    
    The main change here is that the Cmm parser now allows high-level cmm
    code with argument-passing and function calls.  For example:
    
    foo ( gcptr a, bits32 b )
    {
      if (b > 0) {
         // we can make tail calls passing arguments:
         jump stg_ap_0_fast(a);
      }
    
      return (x,y);
    }
    
    More details on the new cmm syntax are in Note [Syntax of .cmm files]
    in CmmParse.y.
    
    The old syntax is still more-or-less supported for those occasional
    code fragments that really need to explicitly manipulate the stack.
    However there are a couple of differences: it is now obligatory to
    give a list of live GlobalRegs on every jump, e.g.
    
      jump %ENTRY_CODE(Sp(0)) [R1];
    
    Again, more details in Note [Syntax of .cmm files].
    
    I have rewritten most of the .cmm files in the RTS into the new
    syntax, except for AutoApply.cmm which is generated by the genapply
    program: this file could be generated in the new syntax instead and
    would probably be better off for it, but I ran out of enthusiasm.
    
    Some other changes in this batch:
    
     - The PrimOp calling convention is gone, primops now use the ordinary
       NativeNodeCall convention.  This means that primops and "foreign
       import prim" code must be written in high-level cmm, but they can
       now take more than 10 arguments.
    
     - CmmSink now does constant-folding (should fix #7219)
    
     - .cmm files now go through the cmmPipeline, and as a result we
       generate better code in many cases.  All the object files generated
       for the RTS .cmm files are now smaller.  Performance should be
       better too, but I haven't measured it yet.
    
     - RET_DYN frames are removed from the RTS, lots of code goes away
    
     - we now have some more canned GC points to cover unboxed-tuples with
       2-4 pointers, which will reduce code size a little.

 compiler/cmm/CLabel.hs                     |   15 +-
 compiler/cmm/Cmm.hs                        |    7 +-
 compiler/cmm/CmmBuildInfoTables.hs         |    7 +-
 compiler/cmm/CmmCallConv.hs                |   66 +-
 compiler/cmm/CmmContFlowOpt.hs             |   12 +-
 compiler/cmm/CmmCvt.hs                     |   33 +-
 compiler/cmm/CmmInfo.hs                    |   46 +-
 compiler/cmm/CmmLayoutStack.hs             |    6 +-
 compiler/cmm/CmmLex.x                      |   16 +-
 compiler/cmm/CmmMachOp.hs                  |    9 +-
 compiler/cmm/CmmNode.hs                    |   46 +-
 compiler/cmm/CmmOpt.hs                     |   21 +-
 compiler/cmm/CmmParse.y                    | 1279 ++++++++++++++++------------
 compiler/cmm/CmmPipeline.hs                |   13 +-
 compiler/cmm/CmmProcPoint.hs               |    7 +-
 compiler/cmm/CmmSink.hs                    |   58 +-
 compiler/cmm/CmmType.hs                    |   18 +-
 compiler/cmm/CmmUtils.hs                   |   18 +-
 compiler/cmm/MkGraph.hs                    |  148 ++--
 compiler/cmm/OldCmm.hs                     |    9 +-
 compiler/cmm/OldPprCmm.hs                  |    8 +-
 compiler/cmm/PprC.hs                       |    1 -
 compiler/cmm/PprCmm.hs                     |   17 +-
 compiler/cmm/SMRep.lhs                     |   37 +-
 compiler/codeGen/CgCallConv.hs             |    9 +-
 compiler/codeGen/CgCon.lhs                 |    4 +-
 compiler/codeGen/CgExtCode.hs              |  241 ------
 compiler/codeGen/CgHeapery.lhs             |    2 +-
 compiler/codeGen/CgProf.hs                 |   13 +-
 compiler/codeGen/CgUtils.hs                |    4 +-
 compiler/codeGen/ClosureInfo.lhs           |   24 +-
 compiler/codeGen/StgCmm.hs                 |    2 +-
 compiler/codeGen/StgCmmBind.hs             |   41 +-
 compiler/codeGen/StgCmmClosure.hs          |   25 +-
 compiler/codeGen/StgCmmCon.hs              |    4 +-
 compiler/codeGen/StgCmmExpr.hs             |    4 +-
 compiler/codeGen/StgCmmExtCode.hs          |  224 +++++
 compiler/codeGen/StgCmmForeign.hs          |   61 +-
 compiler/codeGen/StgCmmGran.hs             |    6 +-
 compiler/codeGen/StgCmmHeap.hs             |  161 ++--
 compiler/codeGen/StgCmmHpc.hs              |    4 +-
 compiler/codeGen/StgCmmLayout.hs           |   44 +-
 compiler/codeGen/StgCmmMonad.hs            |  135 ++-
 compiler/codeGen/StgCmmPrim.hs             |    4 +-
 compiler/codeGen/StgCmmProf.hs             |   35 +-
 compiler/codeGen/StgCmmTicky.hs            |    2 +-
 compiler/codeGen/StgCmmUtils.hs            |    7 +-
 compiler/ghc.cabal.in                      |    2 +-
 compiler/llvmGen/LlvmCodeGen/CodeGen.hs    |    1 -
 compiler/main/HscMain.hs                   |    6 +-
 compiler/nativeGen/AsmCodeGen.lhs          |    9 +-
 compiler/nativeGen/RegAlloc/Linear/Main.hs |   13 +-
 compiler/prelude/ForeignCall.lhs           |   11 +-
 compiler/typecheck/TcForeign.lhs           |    1 -
 includes/Cmm.h                             |  293 +++++--
 includes/Rts.h                             |    1 -
 includes/rts/Constants.h                   |   24 -
 includes/rts/storage/ClosureMacros.h       |    8 -
 includes/rts/storage/ClosureTypes.h        |   55 +-
 includes/rts/storage/Closures.h            |   56 +--
 includes/rts/storage/Liveness.h            |   34 -
 includes/rts/storage/SMPClosureOps.h       |    2 +-
 includes/stg/MiscClosures.h                |   55 +-
 includes/stg/Regs.h                        |  331 +-------
 rts/Apply.cmm                              |   72 +-
 rts/AutoApply.h                            |    8 +-
 rts/ClosureFlags.c                         |    5 +-
 rts/Exception.cmm                          |  242 +++---
 rts/HeapStackCheck.cmm                     |  510 +++++-------
 rts/Interpreter.c                          |   60 +-
 rts/LdvProfile.c                           |    1 -
 rts/Linker.c                               |  577 +++++++-------
 rts/PrimOps.cmm                            | 1163 ++++++++++++--------------
 rts/Printer.c                              |   35 +-
 rts/RaiseAsync.c                           |    2 +-
 rts/RetainerProfile.c                      |   29 +-
 rts/StgMiscClosures.cmm                    |  126 ++-
 rts/StgStartup.cmm                         |   56 +-
 rts/StgStdThunks.cmm                       |  302 +++----
 rts/Updates.cmm                            |   99 +--
 rts/Updates.h                              |   17 +-
 rts/sm/Compact.c                           |   32 +-
 rts/sm/Evac.c                              |    1 -
 rts/sm/Sanity.c                            |   27 -
 rts/sm/Scav.c                              |   26 -
 utils/genapply/GenApply.hs                 |   14 +-
 86 files changed, 3476 insertions(+), 3783 deletions(-)

comment:2 Changed 7 years ago by simonmar

Status: newmerge

comment:3 Changed 7 years ago by simonmar

Owner: simonmar deleted
Status: mergenew

comment:4 Changed 7 years ago by igloo

Resolution: fixed
Status: newclosed

I believe this is now fixed.

Note: See TracTickets for help on using tickets.