summaryrefslogtreecommitdiff
path: root/utils/genprimopcode/Main.hs
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2021-09-10 11:19:28 +0200
committerSebastian Graf <sebastian.graf@kit.edu>2021-09-17 09:36:43 +0200
commit92e0918c6f42223ede5524e3cb91f71728331a9a (patch)
treef28cc283e76ce110f1afb30330ffc559c066e3f6 /utils/genprimopcode/Main.hs
parent3fb1afea019422292954785575902c62473e93e3 (diff)
downloadhaskell-wip/exec-freq.tar.gz
Statically estimate execution frequency of CoreAlts (#20378)wip/exec-freq
This patch implements #20378. See `Note [Estimating CoreAlt frequencies]` in the new module GHC.Core.Opt.ExecFreq for details. These were the changes: 1. Introduce `newtype Freq = Freq Float` as a type that captures relative execution frequency and use it as an additional field in `CoreAlt`. The default when we have no estimate available is `NoFreq`, e.g., NaN. Otherwise, all `Freq`s of a `Case` should add up to 1. Then fix up a whole bunch of use sites. 2. Introduce a new enum `Comparison` for the different kinds of comparison operators (LessThan, GreaterOrEqual, NotEqual, ...). Then make `Compare` primops also declare what kind of `Comparison` they do. Then introduce a function `isComparisonApp_maybe` in GHC.Core.Utils that we can use for our estimates (see below). 3. Write a static analysis pass `estimateAltFreqs`, that annotates `CoreAlt`s with their relative execution `Freq`. These `Freq`s are determined by combining the estimates of different branch heuristics, one of which uses the new `isComparisonApp_maybe`. The main function `estimateAltFreqs` is currently dead, but that is bound to change in follow-up MRs. Fixes #20378.
Diffstat (limited to 'utils/genprimopcode/Main.hs')
-rw-r--r--utils/genprimopcode/Main.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/utils/genprimopcode/Main.hs b/utils/genprimopcode/Main.hs
index 06a4922aa3..fa4605fb69 100644
--- a/utils/genprimopcode/Main.hs
+++ b/utils/genprimopcode/Main.hs
@@ -830,10 +830,10 @@ mkPOI_LHS_text i
mkPOI_RHS_text :: Entry -> String
mkPOI_RHS_text i
= case cat i of
- Compare
+ Compare cmp
-> case ty i of
TyF t1 (TyF _ _)
- -> "mkCompare " ++ sl_name i ++ ppType t1
+ -> "mkCompare " ++ sl_name i ++ cmp ++ " " ++ ppType t1
_ -> error "Type error in comparison op"
GenPrimOp
-> let (argTys, resTy) = flatTys (ty i)