summaryrefslogtreecommitdiff
path: root/compiler/cmm/CmmOpt.hs
Commit message (Collapse)AuthorAgeFilesLines
* Module hierarchy: Cmm (cf #13009)Sylvain Henry2020-01-251-423/+0
|
* PmCheck: Only ever check constantly many models against a single patternSebastian Graf2019-09-251-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Introduces a new flag `-fmax-pmcheck-deltas` to achieve that. Deprecates the old `-fmax-pmcheck-iter` mechanism in favor of this new flag. From the user's guide: Pattern match checking can be exponential in some cases. This limit makes sure we scale polynomially in the number of patterns, by forgetting refined information gained from a partially successful match. For example, when matching `x` against `Just 4`, we split each incoming matching model into two sub-models: One where `x` is not `Nothing` and one where `x` is `Just y` but `y` is not `4`. When the number of incoming models exceeds the limit, we continue checking the next clause with the original, unrefined model. This also retires the incredibly hard to understand "maximum number of refinements" mechanism, because the current mechanism is more general and should catch the same exponential cases like PrelRules at the same time. ------------------------- Metric Decrease: T11822 -------------------------
* Move 'Platform' to ghc-bootJohn Ericson2019-06-191-1/+1
| | | | | | | ghc-pkg needs to be aware of platforms so it can figure out which subdire within the user package db to use. This is admittedly roundabout, but maybe Cabal could use the same notion of a platform as GHC to good affect too.
* Be more selective in which conditionals we invertSimon Marlow2018-03-191-8/+0
| | | | | | | | | | | | Test Plan: validate Reviewers: bgamari, AndreasK, erikd Reviewed By: AndreasK Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4398
* cmm: Remove unnecessary HsVersion.h includesMichal Terepeta2018-02-061-4/+0
| | | | | | | | | | | | Test Plan: ./validate Reviewers: goldfire, bgamari, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4367
* cmm: Optimise remainders by powers of twoBen Gamari2017-11-211-25/+41
| | | | | | | | | | | | | | Test Plan: validate Reviewers: bgamari, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #14437 Differential Revision: https://phabricator.haskell.org/D4180
* compiler: introduce custom "GhcPrelude" PreludeHerbert Valerio Riedel2017-09-191-0/+2
| | | | | | | | | | | | | | | | | | This switches the compiler/ component to get compiled with -XNoImplicitPrelude and a `import GhcPrelude` is inserted in all modules. This is motivated by the upcoming "Prelude" re-export of `Semigroup((<>))` which would cause lots of name clashes in every modulewhich imports also `Outputable` Reviewers: austin, goldfire, bgamari, alanz, simonmar Reviewed By: bgamari Subscribers: goldfire, rwbarton, thomie, mpickering, bgamari Differential Revision: https://phabricator.haskell.org/D3989
* Drop GHC 7.10 compatibilityRyan Scott2017-08-011-2/+0
| | | | | | | | | | | | | | | | GHC 8.2.1 is out, so now GHC's support window only extends back to GHC 8.0. This means we can delete gobs of code that was only used for GHC 7.10 support. Hooray! Test Plan: ./validate Reviewers: hvr, bgamari, austin, goldfire, simonmar Reviewed By: bgamari Subscribers: Phyx, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3781
* Improve code generation for conditionalsSimon Peyton Jones2017-04-281-26/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch in in preparation for the fix to Trac #13397 The code generator has a special case for case tagToEnum (a>#b) of False -> e1 True -> e2 but it was not doing nearly so well on case a>#b of DEFAULT -> e1 1# -> e2 This patch arranges to behave essentially identically in both cases. In due course we can eliminate the special case for tagToEnum#, once we've completed Trac #13397. The changes are: * Make CmmSink swizzle the order of a conditional where necessary; see Note [Improving conditionals] in CmmSink * Hack the general case of StgCmmExpr.cgCase so that it use NoGcInAlts for conditionals. This doesn't seem right, but it's the same choice as the tagToEnum version. Without it, code size increases a lot (more heap checks). There's a loose end here. * Add comments in CmmOpt.cmmMachOpFoldM
* IcmmMachOpFoldM: clarify panic messageSergei Trofimovich2017-02-111-1/+1
| | | | | | | | | | | When adding a new primop cinimod noticed uninformative ghc panic: cmmMachOpFoldM: unknown unary op This change tweaks panic to contain the op: cmmMachOpFoldM: unknown unary op: MO_F_Neg W64 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* Turn divInt# and modInt# into bitwise operations when possibleTakano Akio2016-09-051-20/+1
| | | | | | | | | | | | | | | | | | | This implements #5615 for divInt# and modInt#. I also included rules to do constant-folding when the both arguments are known. Test Plan: validate Reviewers: austin, simonmar, bgamari Reviewed By: bgamari Subscribers: hvr, thomie Differential Revision: https://phabricator.haskell.org/D2486 GHC Trac Issues: #5615
* Reduce default for -fmax-pmcheck-iterations from 1e7 to 2e6Herbert Valerio Riedel2016-04-101-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | The commit 28f951edfe50ea5182065144340061ec326781f5 introduced the `-fmax-pmcheck-iterations` flag and set the default limit to 1e7 iterations. However, this value is still high enough that it can result GHC to exhibit memory spikes beyond 1 GiB of RAM usage (heap profile showed several `(:)`s, as well as `THUNK_2_0`, and `PmCon` during the memory spikes) A value of 2e6 seems to be a safer upper bound which still manages to let the checker not run into the limit in most cases. Test Plan: Validate, try building a few Hackage packages Reviewers: austin, gkaracha, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2095
* Refactor: delete most of the module FastTypesThomas Miedema2015-08-211-18/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverses some of the work done in #1405, and goes back to the assumption that the bootstrap compiler understands GHC-haskell. In particular: * use MagicHash instead of _ILIT and _CLIT * pattern matching on I# if possible, instead of using iUnbox unnecessarily * use Int#/Char#/Addr# instead of the following type synonyms: - type FastInt = Int# - type FastChar = Char# - type FastPtr a = Addr# * inline the following functions: - iBox = I# - cBox = C# - fastChr = chr# - fastOrd = ord# - eqFastChar = eqChar# - shiftLFastInt = uncheckedIShiftL# - shiftR_FastInt = uncheckedIShiftRL# - shiftRLFastInt = uncheckedIShiftRL# * delete the following unused functions: - minFastInt - maxFastInt - uncheckedIShiftRA# - castFastPtr - panicDocFastInt and pprPanicFastInt * rename panicFastInt back to panic# These functions remain, since they actually do something: * iUnbox * bitAndFastInt * bitOrFastInt Test Plan: validate Reviewers: austin, bgamari Subscribers: rwbarton Differential Revision: https://phabricator.haskell.org/D1141 GHC Trac Issues: #1405
* Add LANGUAGE pragmas to compiler/ source filesHerbert Valerio Riedel2014-05-151-0/+2
| | | | | | | | | | | | | | | | | | In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been reorganized, while following the convention, to - place `{-# LANGUAGE #-}` pragmas at the top of the source file, before any `{-# OPTIONS_GHC #-}`-lines. - Moreover, if the list of language extensions fit into a single `{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each individual language extension. In both cases, try to keep the enumeration alphabetically ordered. (The latter layout is preferable as it's more diff-friendly) While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
* Allow the argument to 'reserve' to be a compile-time expressionSimon Marlow2014-01-161-0/+12
| | | | By using the constant-folder to reduce it to an integer.
* Remove unused codeJan Stolarek2013-10-161-48/+0
| | | | | | | I am removing old loopification code that has been commented out for long long time. We now have loopification implemented in the code generator (see Note [Self-recursive tail calls]) so we won't need to resurect this old code.
* Trailing whitespacesJan Stolarek2013-10-161-5/+4
|
* Fix warningsSimon Marlow2012-11-121-1/+0
|
* Remove OldCmm, convert backends to consume new CmmSimon Marlow2012-11-121-3/+4
| | | | | | | | | | | | | | | | | | This removes the OldCmm data type and the CmmCvt pass that converts new Cmm to OldCmm. The backends (NCGs, LLVM and C) have all been converted to consume new Cmm. The main difference between the two data types is that conditional branches in new Cmm have both true/false successors, whereas in OldCmm the false case was a fallthrough. To generate slightly better code we occasionally need to invert a conditional to ensure that the branch-not-taken becomes a fallthrough; this was previously done in CmmCvt, and it is now done in CmmContFlowOpt. We could go further and use the Hoopl Block representation for native code, which would mean that we could use Hoopl's postorderDfs and analyses for native code, but for now I've left it as is, using the old ListGraph representation for native code.
* Attach global register liveness info to Cmm procedures.Geoffrey Mainland2012-10-301-2/+2
| | | | | | | All Cmm procedures now include the set of global registers that are live on procedure entry, i.e., the global registers used to pass arguments to the procedure. Only global registers that are use to pass arguments are included in this list.
* a small -fPIC optimisationSimon Marlow2012-10-231-0/+14
| | | | (PicBaseReg + lit) + N ==> PicBaseReg + (lit+N)
* Produce new-style Cmm from the Cmm parserSimon Marlow2012-10-081-10/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove some old-codegen cruftSimon Marlow2012-09-251-269/+0
|
* Pass DynFlags down to wordWidthIan Lynagh2012-09-121-43/+42
|
* Make tablesNextToCode "dynamic"Ian Lynagh2012-08-061-6/+5
| | | | | This is a bit odd by itself, but it's a stepping stone on the way to putting "target unregisterised" into the settings file.
* commentSimon Marlow2012-08-061-0/+5
|
* New codegen: do not split proc-points when using the NCGSimon Marlow2012-07-301-4/+6
| | | | | | | | | Proc-point splitting is only required by backends that do not support having proc-points within a code block (that is, everything except the native backend, i.e. LLVM and C). Not doing proc-point splitting saves some compilation time, and might produce slightly better code in some cases.
* Fix merge-related problemsSimon Marlow2012-07-041-3/+3
|
* Merge remote-tracking branch 'origin/master' into newcgSimon Marlow2012-07-041-14/+17
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * origin/master: (756 commits) don't crash if argv[0] == NULL (#7037) -package P was loading all versions of P in GHCi (#7030) Add a Note, copying text from #2437 improve the --help docs a bit (#7008) Copy Data.HashTable's hashString into our Util module Build fix Build fixes Parse error: suggest brackets and indentation. Don't build the ghc DLL on Windows; works around trac #5987 On Windows, detect if DLLs have too many symbols; trac #5987 Add some more Integer rules; fixes #6111 Fix PA dfun construction with silent superclass args Add silent superclass parameters to the vectoriser Add silent superclass parameters (again) Mention Generic1 in the user's guide Make the GHC API a little more powerful. tweak llvm version warning message New version of the patch for #5461. Fix Word64ToInteger conversion rule. Implemented feature request on reconfigurable pretty-printing in GHCi (#5461) ... Conflicts: compiler/basicTypes/UniqSupply.lhs compiler/cmm/CmmBuildInfoTables.hs compiler/cmm/CmmLint.hs compiler/cmm/CmmOpt.hs compiler/cmm/CmmPipeline.hs compiler/cmm/CmmStackLayout.hs compiler/cmm/MkGraph.hs compiler/cmm/OldPprCmm.hs compiler/codeGen/CodeGen.lhs compiler/codeGen/StgCmm.hs compiler/codeGen/StgCmmBind.hs compiler/codeGen/StgCmmLayout.hs compiler/codeGen/StgCmmUtils.hs compiler/main/CodeOutput.lhs compiler/main/HscMain.hs compiler/nativeGen/AsmCodeGen.lhs compiler/simplStg/SimplStg.lhs
| * Remove some more redundant Platform argumentsIan Lynagh2012-06-201-3/+3
| |
| * Pass DynFlags down to showSDocIan Lynagh2012-06-121-15/+17
| |
| * Fix the unregisterised build; fixes #5901Ian Lynagh2012-02-271-2/+3
| |
| * Add a Word add-with-carry primopIan Lynagh2012-02-231-2/+2
| | | | | | | | No special-casing in any NCGs yet
* | a couple of minor optimisationsSimon Marlow2012-03-151-3/+2
| |
* | fix another bug in CmmOptSimon Marlow2012-03-091-3/+7
| |
* | fixes to the mini-inliner (fixes stage2 crashes)Simon Marlow2012-03-061-12/+13
| |
* | Revert "Revert "Improvements to the mini-inliner""Simon Marlow2012-03-061-41/+40
| | | | | | | | This reverts commit 5ff03ca7f3b5b1abad64c039fa20165b4cf77360.
* | Revert "Improvements to the mini-inliner"Simon Marlow2012-03-021-40/+41
| | | | | | | | This reverts commit 3d8ab554ced45c51f39951f29cc53277d5788c37.
* | Improvements to the mini-inlinerSimon Marlow2012-02-151-41/+40
|/ | | | | | | - inline x = R1, even if x occurs many times - inline past a store, if the expression is not a load (we could further refine this of course, but the idea here is to get reasonable code for not much effort)
* Track STG live register information for use in LLVMDavid Terei2012-01-091-3/+3
| | | | | | | | | We now carry around with CmmJump statements a list of the STG registers that are live at that jump site. This is used by the LLVM backend so it can avoid unnesecarily passing around dead registers, improving perfromance. This gives us the framework to finally fix trac #4308.
* Remove unused arg field of CmmReturnDavid Terei2012-01-051-1/+1
|
* Remove unused argument field on CmmJumpDavid Terei2012-01-051-3/+3
|
* Get rid of the "safety" field of CmmCall (OldCmm)Simon Marlow2011-11-291-3/+3
| | | | | This field was doing nothing. I think it originally appeared in a very old incarnation of the new code generator.
* Fix warnings in cmm/CmmOpt.hsIan Lynagh2011-11-051-102/+94
|
* Finish de-CPPing CmmOpt.hsIan Lynagh2011-11-051-40/+39
|
* Fix bitrotted NCG_DEBUG code, and switch to using a Haskell conditionalIan Lynagh2011-11-051-23/+22
|
* Renaming onlySimon Peyton Jones2011-08-251-1/+1
| | | | | CmmTop -> CmmDecl CmmPgm -> CmmGroup
* Refactoring: explicitly mark whether we have an info table in RawCmmMax Bolingbroke2011-07-061-6/+5
| | | | | | | | | | | | I introduced this to support explicitly recording the info table label in RawCmm for another patch I am working on, but it turned out to lead to significant simplification in those parts of the compiler that consume RawCmm. Now, instead of lots of tests for null [CmmStatic] we have a simple test of a Maybe, and have reduced the number of guys that need to know how to convert entry->info labels by a TON. There are only 3 callers of that function now!
* Iteratively try to fold expressions before constant propagationJohan Tibell2011-06-231-2/+5
| | | | | | | | | | | | | Before this change the constant expression _ccI::I64 = (16 >> 7) + 1; wouldn't be propagated, as it wouldn't be completely folded. This meant that this expression wouldn't be unrolled thawArray# arr# 0# 16# s# The new code generator already does this correctly.
* Port MachOp folding to new code generator.Edward Z. Yang2011-06-171-179/+187
| | | | | | | | | | | | | | | * Rewrote cmmMachOpFold to cmmMachOpFoldM, which returns Nothing if no folding took place. * Wrote some generic mapping functions which take functions of form 'a -> Maybe a' and are smart about sharing. * Split up optimizations from PIC and PPC work in the native codegen, so they'll be easier to turn off later (they are not currently being turned off, however.) * Whitespace fixes! ToDo: Turn off MachOp folding when new codegenerator is being used. Signed-off-by: Edward Z. Yang <ezyang@mit.edu>