Skip to content

optimize Symbol with constant string argument #32437

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

Merged
merged 1 commit into from
Nov 30, 2019
Merged

Conversation

JeffBezanson
Copy link
Member

Currently code with Symbol("x") instead of :x does not get optimized at all, which could be a gotcha. Allow constant inferring symbol<->string conversions, and allow Symbol as an inlined constant.

@JeffBezanson JeffBezanson added compiler:inference Type inference compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) labels Jun 27, 2019
ncodeunits(s::String) = Core.sizeof(s)
sizeof(s::String) = Core.sizeof(s)
@pure ncodeunits(s::String) = Core.sizeof(s)
@pure sizeof(s::String) = Core.sizeof(s)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think inference is supposed to know this one already, and might just need a minor fix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually a while ago I specifically told the compiler not to constant prop Strings since it led to extremely long compile times for some packages (if I recall, DiffEq parsing many string literals to input numeric constants).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

purity detection should be able to infer this independently of constant prop though and mark it as pure

@vtjnash
Copy link
Member

vtjnash commented Jun 27, 2019

Conflicts with the premise of #32368, but otherwise this does seem desirable.

@StefanKarpinski
Copy link
Member

Bump.

@nalimilan
Copy link
Member

Re-bump.

@StefanKarpinski
Copy link
Member

Re-re-bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference compiler:optimizer Optimization passes (mostly in base/compiler/ssair/)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants