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

Copy/paste error in GenTree::GetRegSpillFlagByIdx for xarch hwintrinsics #52473

Closed
BruceForstall opened this issue May 7, 2021 · 5 comments
Closed
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@BruceForstall
Copy link
Member

In GenTree::GetRegSpillFlagByIdx the following code exists:

#if defined(TARGET_XARCH) && defined(FEATURE_HW_INTRINSICS)
if (OperIs(GT_HWINTRINSIC))
{
// At this time, the only multi-reg HW intrinsics all return the type of their
// arguments. If this changes, we will need a way to record or determine this.
assert(TypeGet() == TYP_STRUCT);
return gtGetOp1()->TypeGet();
}
#endif

This makes no sense, as the function is supposed to return a GTF_SPILL / GTF_SPILLED mask, but in this case it is returning a type, instead.

This code is an exact copy of code in GenTree::GetRegTypeByIndex, immediately above.

So what should it return in this case?

@tannergooding @echesakovMSFT @dotnet/jit-contrib

@BruceForstall BruceForstall added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 7, 2021
@BruceForstall BruceForstall added this to the 6.0.0 milestone May 7, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label May 7, 2021
@BruceForstall BruceForstall removed the untriaged New issue has not been triaged by the area owner label May 7, 2021
@tannergooding
Copy link
Member

tannergooding commented May 7, 2021

Looks like this was introduced in #36155. CC @sandreenko

I'd speculate it needs to just be AsHWIntrinsic()->GetRegSpillFlagByIdx(regIndex);, like the other paths are doing given that GetRegSpillFlagByIdx was a new instance method added to GenTree at the same.

We'd then need to implement the GenTreeHWIntrinsic::GetRegSpillFlagByIdx(unsigned idx). Other methods do this by tracking MultiRegSpillFlags gtSpillFlags; as a field and then doing return GetMultiRegSpillFlagsByIdx(gtSpillFlags, idx);

@sandreenko
Copy link
Contributor

I agree with @tannergooding analysis, looks like this error does not produce any failures because we don't set the spill flag currently, so the return value is always treated as "no spill flags" for any var_type.
Why don't we set the spill flag currently? It is because we don't expect it here:

// rsSpillTree: Spill the tree held in 'reg'.

so looks like there are several pieces that are missed, what are the current multireg HWIntrinsics that return multireg results? I assume they have to return structs based on:

#if defined(TARGET_XARCH) && defined(FEATURE_HW_INTRINSICS)
if (OperIs(GT_HWINTRINSIC))
{
return (TypeGet() == TYP_STRUCT);
}

@tannergooding
Copy link
Member

what are the current multireg HWIntrinsics that return multireg results?

I don't think we have any officially doing it today. #52424 will be adding the LoadPair intrinsics which will do multi-reg returns.

Carol had started a prototype for this on Bmi2.MultiplyNoFlags on the x86 side, but I don't think it was ever completed: https://github.com/CarolEidt/runtime/tree/Mulx2

@echesakov
Copy link
Contributor

I will take this

@BruceForstall
Copy link
Member Author

This code has been fixed.

@ghost ghost locked as resolved and limited conversation to collaborators Aug 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

No branches or pull requests

5 participants