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
Consider inlining fldmod
to allow optimizing if an arg is a Const
#30333
Comments
Is this on 1.0 or on 1.X-dev? And do you have a MWE?
-- edit: |
Yeah only one of the arguments is const. |
We talked in person, maybe the better, broader solution is to change the inlining heuristics to be aware of constant propagation. So, if inlining might not seem worth it on its face, but it allows you to propagate a Const you couldn't do otherwise, that should increase the likelihood of inlining by some degree. Based on some preliminary exploration, maybe that change could be something like adding a check into this function: julia/base/compiler/optimize.jl Lines 360 to 361 in 73c8eb4
that if any of the arguments to this are |
|
Opening an issue based on this discussion: JuliaMath/FixedPointDecimals.jl#43 (review)
In our code,
fldmod
isn't inlining. Where we are calling it, one of the arguments is a static compiler Const, and so the division could be optimized away (into a cheaper multiplication and bitshift -- explanation here: JuliaMath/FixedPointDecimals.jl#43 (comment)), but it isn't able to because the non-inlinedfldmod
presents a function barrier that prevents the compiler from knowing one of the arguments is a Const.fldmod
is such a simple function, so i'm surprised it wasn't inlining anyway. Would it make sense to mark this as@inline
in Base? If you think so, i can send a PR to do it.The text was updated successfully, but these errors were encountered: