-
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
Clash not inlining certain floating point subtractions #2097
Comments
Ah, the issue is simply that we haven't added support for matching on Float literals, like we do for Integer and Natural literals: clash-compiler/clash-lib/src/Clash/Normalize/Transformations.hs Lines 761 to 853 in fa01fd9
|
In the primitives unpackFloat# and unpackDouble#, the result from the primitive evaluator was an unboxed literal (i.e. Float#) when the actual result of the function is a boxed literal (i.e. Float). This led to #2097 having core that looked like ``` case 1.0# of F# x -> ... ``` which will rightly never match. When the primitives instead return the correct type we get a case expression ``` case F# 1.0# of F# x -> ... ``` where the caseCon transformation can fire.
So a few things here:
However, this still doesn't make this particular example compile. We're missing the primitives PR incoming... |
In the primitives unpackFloat# and unpackDouble#, the result from the primitive evaluator was an unboxed literal (i.e. Float#) when the actual result of the function is a boxed literal (i.e. Float). This led to #2097 having core that looked like ``` case 1.0# of F# x -> ... ``` which will rightly never match. When the primitives instead return the correct type we get a case expression ``` case F# 1.0# of F# x -> ... ``` where the caseCon transformation can fire.
In the primitives unpackFloat# and unpackDouble#, the result from the primitive evaluator was an unboxed literal (i.e. Float#) when the actual result of the function is a boxed literal (i.e. Float). This led to #2097 having core that looked like ``` case 1.0# of F# x -> ... ``` which will rightly never match. When the primitives instead return the correct type we get a case expression ``` case F# 1.0# of F# x -> ... ``` where the caseCon transformation can fire.
In the primitives unpackFloat# and unpackDouble#, the result from the primitive evaluator was an unboxed literal (i.e. Float#) when the actual result of the function is a boxed literal (i.e. Float). This led to #2097 having core that looked like ``` case 1.0# of F# x -> ... ``` which will rightly never match. When the primitives instead return the correct type we get a case expression ``` case F# 1.0# of F# x -> ... ``` where the caseCon transformation can fire. (cherry picked from commit 31c25df)
Compiling this:
errors with:
Clash seems to have trouble with the
Float
subtraction in(-) a b = bitCoerce @Float (bitCoerce a - bitCoerce b)
needed to evaluate the literal-1 :: MyFloat
.Changing
topEntity
to-1 :: Float
does compile on the other hand.The text was updated successfully, but these errors were encountered: