-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inlineCleanup
introduces free variables
#1337
Labels
Comments
Ah, this only triggers after this patch: diff --git a/clash-lib/src/Clash/Normalize/Transformations.hs b/clash-lib/src/Clash/Normalize/Transformations.hs
index 8706b3cc..bb2dde34 100644
--- a/clash-lib/src/Clash/Normalize/Transformations.hs
+++ b/clash-lib/src/Clash/Normalize/Transformations.hs
@@ -2148,8 +2148,9 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
| n == 0 -> changed rArg
| m == 0 -> changed lArg
| otherwise -> do
- shouldReduce1 <- List.orM [ shouldReduce ctx
- , isUntranslatableType_not_poly aTy ]
+ shouldReduce1 <- List.orM [ pure ultra
+ , shouldReduce ctx
+ , isUntranslatableType_not_poly aTy ]
if shouldReduce1
then (`mkTicks` ticks) <$> reduceAppend is0 n m aTy lArg rArg
else return e
@@ -2159,8 +2160,9 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
[vArg] = Either.lefts args
case runExcept (tyNatSize tcm nTy) of
Right n -> do
- shouldReduce1 <- List.orM [ shouldReduce ctx
- , isUntranslatableType_not_poly aTy ]
+ shouldReduce1 <- List.orM [ pure ultra
+ , shouldReduce ctx
+ , isUntranslatableType_not_poly aTy ]
if shouldReduce1
then (`mkTicks` ticks) <$> reduceHead is0 (n+1) aTy vArg
else return e
@@ -2170,8 +2172,9 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
[vArg] = Either.lefts args
case runExcept (tyNatSize tcm nTy) of
Right n -> do
- shouldReduce1 <- List.orM [ shouldReduce ctx
- , isUntranslatableType_not_poly aTy ]
+ shouldReduce1 <- List.orM [ pure ultra
+ , shouldReduce ctx
+ , isUntranslatableType_not_poly aTy ]
if shouldReduce1
then (`mkTicks` ticks) <$> reduceTail is0 (n+1) aTy vArg
else return e
@@ -2181,9 +2184,10 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
[vArg] = Either.lefts args
case runExcept (tyNatSize tcm nTy) of
Right n -> do
- shouldReduce1 <- List.orM [ shouldReduce ctx
- , isUntranslatableType_not_poly aTy
- ]
+ shouldReduce1 <- List.orM [ pure ultra
+ , shouldReduce ctx
+ , isUntranslatableType_not_poly aTy
+ ]
if shouldReduce1
then (`mkTicks` ticks) <$> reduceLast is0 (n+1) aTy vArg
else return e
@@ -2193,8 +2197,9 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
[vArg] = Either.lefts args
case runExcept (tyNatSize tcm nTy) of
Right n -> do
- shouldReduce1 <- List.orM [ shouldReduce ctx
- , isUntranslatableType_not_poly aTy ]
+ shouldReduce1 <- List.orM [ pure ultra
+ , shouldReduce ctx
+ , isUntranslatableType_not_poly aTy ]
if shouldReduce1
then (`mkTicks` ticks) <$> reduceInit is0 (n+1) aTy vArg
else return e
@@ -2213,9 +2218,10 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
let ([_sArg,vArg],[nTy,aTy]) = Either.partitionEithers args
case runExcept (tyNatSize tcm nTy) of
Right n -> do
- shouldReduce1 <- List.orM [ shouldReduce ctx
- , isUntranslatableType_not_poly aTy
- ]
+ shouldReduce1 <- List.orM [ pure ultra
+ , shouldReduce ctx
+ , isUntranslatableType_not_poly aTy
+ ]
if shouldReduce1
then (`mkTicks` ticks) <$> reduceReplicate n aTy eTy vArg
else return e
@@ -2279,8 +2285,9 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
let ([_sArg,vArg],[nTy,aTy]) = Either.partitionEithers args
case runExcept (tyNatSize tcm nTy) of
Right n -> do
- shouldReduce1 <- List.orM [ shouldReduce ctx
- , isUntranslatableType False aTy ]
+ shouldReduce1 <- List.orM [ pure ultra
+ , shouldReduce ctx
+ , isUntranslatableType False aTy ]
if shouldReduce1
then (`mkTicks` ticks) <$> reduceTReplicate n aTy eTy vArg
else return e so it might just be edit: cleaned up patch |
Actually, I just need to make |
A lot of that patch just seems to be whitespace changes |
martijnbastiaan
added a commit
that referenced
this issue
May 20, 2020
martijnbastiaan
added a commit
that referenced
this issue
May 20, 2020
martijnbastiaan
added a commit
that referenced
this issue
May 20, 2020
martijnbastiaan
added a commit
that referenced
this issue
May 20, 2020
martijnbastiaan
added a commit
that referenced
this issue
May 20, 2020
martijnbastiaan
added a commit
that referenced
this issue
May 25, 2020
martijnbastiaan
added a commit
that referenced
this issue
May 25, 2020
martijnbastiaan
added a commit
that referenced
this issue
May 25, 2020
martijnbastiaan
added a commit
that referenced
this issue
May 25, 2020
christiaanb
pushed a commit
that referenced
this issue
May 25, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated issue report 19 May 2020:
If
inlineCleanup
is given an expression of the following form:Depending on the actual expressions that the various binders represent, it will determine
result
is a binding that should be "kept", while all others should be inlined.inlineBndrsCleanup
will try to do this, but it currently fails to handle this case correctly. It will yield:i.e., it will introduce a free variable!
Original issue report 18 May 2020:
Compiling the following:
with
cabal new-run clash -- Test.hs --vhdl -fclash-debug DebugSilent -fclash-compile-ultra
yields:
The text was updated successfully, but these errors were encountered: