Skip to content
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

Simplify floating point mod and round jit helpers implementations #100222

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Mar 25, 2024

No description provided.

@jkotas
Copy link
Member Author

jkotas commented Mar 25, 2024

Peeled from #98858

@jkotas
Copy link
Member Author

jkotas commented Mar 25, 2024

cc @MichalPetryka

Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@jkotas jkotas changed the title Rewrite floating point mod and round math jit helpers to managed code Simplify floating point mod and round jit helpers implementations Mar 25, 2024

DEFINE_CLASS(MATHF, System, MathF)
DEFINE_METHOD(MATHF, ROUND, Round, SM_Flt_RetFlt)
DEFINE_METHOD(MATHF, FMOD, FMod, NoSig)
Copy link
Member

Choose a reason for hiding this comment

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

Can we also just remove Math.FMod

We can just replace any calls with simply x % y, since that does the same thing

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also just remove Math.FMod

We can just replace any calls with simply x % y, since that does the same thing

Won't this make porting FMod/% to a full managed impl harder later on?

Also FMod has some special intrinsic recognition in the JIT, not sure if % has the same today.

Copy link
Member Author

Choose a reason for hiding this comment

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

Won't this make porting FMod/% to a full managed impl harder later on?

If FMod is ever ported to a fully managed impl, this can be adjusted as necessary.

Also FMod has some special intrinsic recognition in the JIT, not sure if % has the same today.

% has same value numbering support as FMod.

break;
case ReadyToRunHelper.FltRem:
mangledName = "RhpFltRem";
mangledName = "fmodf";
break;

Copy link
Contributor

Choose a reason for hiding this comment

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

Just noticed that DblRound/FltRound are unhandled here (and on main), would it make sense to readd handling for them at least until they're fully removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure what you mean by unhandled. Could you please elaborate?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure what you mean by unhandled. Could you please elaborate?

There seems to be no switch case for them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
case ReadyToRunHelper.DblRound:
DefType doubleType = context.GetWellKnownType(WellKnownType.Double);
methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("Round",
new MethodSignature(MethodSignatureFlags.Static, 0, doubleType, [doubleType]));
break;
case ReadyToRunHelper.FltRound:
DefType floatType = context.GetWellKnownType(WellKnownType.Single);
methodDesc = context.SystemModule.GetKnownType("System", "MathF").GetKnownMethod("Round",
new MethodSignature(MethodSignatureFlags.Static, 0, floatType, [floatType]));
break;

if we want to add them here.

Copy link
Member Author

Choose a reason for hiding this comment

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

This mapping is native AOT specific. It does not need to handle JIT helpers that are no longer used or that are only used outside native AOT.

@jkotas jkotas merged commit 503970c into dotnet:main Mar 26, 2024
171 of 174 checks passed
@jkotas jkotas deleted the math-helpers-floatingpoint branch March 27, 2024 13:43
@github-actions github-actions bot locked and limited conversation to collaborators Apr 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants