[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 14 commits: Cleanup a TODO introduced in 1f94e0f7

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Wed Aug 9 16:24:27 UTC 2023



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
0479241f by Sebastian Graf at 2023-08-09T12:24:21-04:00
Cleanup a TODO introduced in 1f94e0f7

The change must have slipped through review of !4412

- - - - -
0a27bceb by Sebastian Graf at 2023-08-09T12:24:21-04:00
More explicit strictness in GHC.Real

- - - - -
2c86b0d0 by Sebastian Graf at 2023-08-09T12:24:21-04:00
exprIsTrivial: Factor out shared implementation

The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has
been bugging me for a long time.

This patch introduces an inlinable worker function `trivial_expr_fold` acting
as the single, shared decision procedure of triviality. It "returns" a
Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar
code as before.
(Better code, even, in the case of `getIdFromTrivialExpr` which presently
allocates a `Just` constructor that cancels away after this patch.)

- - - - -
3aeeab99 by Sebastian Graf at 2023-08-09T12:24:21-04:00
Simplify: Simplification of arguments in a single function

The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`,
which seems to be the main way to simplify args. Hence I consolidated the code
path to call `simplArg`, too, renaming to `simplLazyArg`.

- - - - -
22288b47 by Sebastian Graf at 2023-08-09T12:24:21-04:00
Core.Ppr: Omit case binder for empty case alternatives

A minor improvement to pretty-printing

- - - - -
835fbba8 by Sebastian Graf at 2023-08-09T12:24:22-04:00
Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend

... because those coerce between incompatible/unknown PrimReps.

- - - - -
bab9d2a5 by Sebastian Graf at 2023-08-09T12:24:22-04:00
Inlining literals into boring contexts is OK

- - - - -
3535969b by Sebastian Graf at 2023-08-09T12:24:22-04:00
Clarify floating of unsafeEqualityProofs (#23754)

- - - - -
bd5a3e73 by Sebastian Graf at 2023-08-09T12:24:22-04:00
Kill SetLevel.notWorthFloating.is_triv (#23270)

We have had it since b84ba676034, when it operated on annotated expressions.
Nowadays it operates on vanilla `CoreExpr` though, so we should just call
`exprIsTrivial`; thus handling empty cases and string literals correctly.

- - - - -
86eb02a6 by Sebastian Graf at 2023-08-09T12:24:22-04:00
ANFise string literal arguments (#23270)

This instates the invariant that a trivial CoreExpr translates to an atomic
StgExpr. Nice.

Annoyingly, in -O0 we sometimes generate
```
foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat }
```
which makes it a bit harder to spot that we can emit a standard
`stg_unpack_cstring` thunk.

Fixes #23270.

- - - - -
80a6fb5b by Sebastian Graf at 2023-08-09T12:24:22-04:00
Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345)

- - - - -
fb43ba50 by Sebastian Graf at 2023-08-09T12:24:22-04:00
CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead

We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now.
The main reason is that it plays far better in conjunction with eta expansion
(as we aim to do for arguments in CorePrep, #23083), because we can discard
any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta`
it's impossible to discard the argument.

We do also give the same treatment to unsafeCoerce proofs and treat them as
trivial iff their RHS is trivial.

It is also both much simpler to describe than the previous mechanism of emitting
an unsafe coercion and simpler to implement, removing quite a bit of commentary
and `CorePrepProv`.

In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier
iteration due to #17910. E.g., FloatOut produces a binding
```
lvl_s6uK [Occ=Once1] :: GHC.Types.Int
[LclId]
lvl_s6uK = GHC.Types.I# 2#

lvl_s6uL [Occ=Once1] :: GHC.Types.Any
[LclId]
lvl_s6uL
  = case Unsafe.Coerce.unsafeEqualityProof ... of
    { Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...)
    }
```
That occurs once and hence is pre-inlined unconditionally in the next Simplifier
pass. It's non-trivial to find a way around that, but not really harmful
otherwise. Hence we accept a 1.2% increase on some architectures.

Metric Increase:
    LargeRecord

- - - - -
14c21078 by Sebastian Graf at 2023-08-09T12:24:22-04:00
CorePrep: Eta expand arguments (#23083)

Previously, we'd only eta expand let bindings and lambdas,
now we'll also eta expand arguments such as in T23083:
```hs
g f h = f (h `seq` (h $))
```
Unless `-fpedantic-bottoms` is set, we'll now transform to
```hs
g f h = f (\eta -> h eta)
```
in CorePrep.

See the new `Note [Eta expansion of arguments in CorePrep]` for the details.

We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions
in T4801 and T5321FD.

Fixes #23083.

- - - - -
63ea031c by Matthew Craven at 2023-08-09T12:24:22-04:00
Bump bytestring submodule to 0.11.5, again

Fixes #23789.

The bytestring commit used here is unreleased;
a release can be made when necessary.

- - - - -


30 changed files:

- .gitlab-ci.yml
- compiler/GHC/Core.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/Coercion/Opt.hs
- compiler/GHC/Core/FVs.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Ppr.hs
- compiler/GHC/Core/TyCo/FVs.hs
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/TyCo/Tidy.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Core/Unfold.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/CoreToIface.hs
- compiler/GHC/CoreToStg.hs
- compiler/GHC/CoreToStg/Prep.hs
- compiler/GHC/Driver/Config/CoreToStg/Prep.hs
- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Type.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/Stg/Syntax.hs
- compiler/GHC/StgToCmm/Bind.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2d4ddd7e3fefc1e4bd10c4786370e7a3a345fe25...63ea031c7fbe5a50e5125d53710c95ebed4aa4d6

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2d4ddd7e3fefc1e4bd10c4786370e7a3a345fe25...63ea031c7fbe5a50e5125d53710c95ebed4aa4d6
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230809/ad3d4a49/attachment.html>


More information about the ghc-commits mailing list