Fix regression in let floating, which can cause agressive inlining (#91)
commit52d4b880ef28d693ebdb498fb37cb36e8a836e1d
authorNathan Faubion <natefaubion@users.noreply.github.com>
dateThu 17 Aug 2023, 10:31 (3 years ago)
parentcf21ff5
backend-es/test/snapshots-out/Snapshot.FloatLetRegression01.jsnew file+5
@@ -0,0 +1,5 @@
1+const test = f => {
2+ const c = f(2);
3+ return {b: f(1), c1: c, c2: c};
4+};
5+export {test};
backend-es/test/snapshots/Snapshot.FloatLetRefression01.pursnew file+14
@@ -0,0 +1,14 @@
1+module Snapshot.FloatLetRegression01 where
2+
3+test :: (Int -> Int) -> { b :: Int, c1 :: Int, c2 :: Int }
4+test f =
5+ ( let
6+ b = f 1
7+ in
8+ ( let
9+ c = f 2
10+ in
11+ { x: { y: { b, c1: c, c2: c } } }
12+ ).x
13+ ).y
14+
src/PureScript/Backend/Optimizer/Semantics.purs+2−2
@@ -607,8 +607,8 @@ floatLetWith = go
607607 where
608608 go f ident1 binding1 k1 = case binding1 of
609609 SemLet ident2 binding2 k2 ->
610− go f ident2 binding2 \nextBinding2 ->
611− makeLet ident1 (k2 nextBinding2) k1
610+ go makeLet ident2 binding2 \nextBinding2 ->
611+ f ident1 (k2 nextBinding2) k1
612612 SemLetRec bindings k2 ->
613613 SemLetRec bindings \nextBindings ->
614614 makeLet ident1 (k2 nextBindings) k1