-
Notifications
You must be signed in to change notification settings - Fork 789
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
Change ty.Equals(typeof<'T>) to Type.op_Equality(typeof<'T>, ty) to please RyuJIT #8447
Comments
This would make for a good PR I think. Can't think of a downside here. |
|
Right... It's a shame Type is a non-framework inheritable class. I suppose you could still do a static optimization when typeof appears on the left hand side but all that is probably more trouble than it's worth. Judicious use of |
We could do optimization of |
Same for |
There are some dynamic type checks here and there in FSharp.Core that all use Type.Equals instead of Type.op_Equality. Only the latter is optimized by the JIT for branch elimination (reference vs value type) and lookup table transformation for shared reference type checks. That's some easy free perf on the generic equality.
fsharp/src/fsharp/FSharp.Core/prim-types.fs
Lines 2341 to 2357 in db2ba9e
https://sharplab.io/#v2:DYLgZgzgNALiCGEC2AfA9gBwKYDsAEAygJ4QxZICwAUJroQBbwBOGAMvAEYB0ASgK44YASyRZq1GEWx4AwgAoAlHgC81POrwBtADwApITADiuLEyEBjOZOxow2oYIB8CxwF01G0vGHm8opBymhMBoAO7aAOQAKo6KKngeGhpI3ub0eNZYtpExeKEG6YlJeCgZRHn0dJJcAKIAjnzwwBBWUll2DjDOeAC0jngAjEVJpZIVVUS1DU0tmdkcaGjA3X14AEzDGqPloZX41fWNza02dhxEZCv9AMyb6qUA+r39ACx3CVRJOvpGJmaWcw6Thc7k+nhg3gsfnIgSYeAAYogYDlYkplB9islUulASi8gUMZiShlxvgom0uJgHocmgYiFYoGVTvZgc9Bu9RqS8OTsJSMNTpsA6Qyme1tAslld1hySbs6DysHyBUdhTBGbjzpclKtbmDMY82W8qEA=
Ideally I'd like to see a static optimization for
(=) (x:Type, y:Type)
to useType.op_Equality
@dsyme is this something you're ok with?The text was updated successfully, but these errors were encountered: