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

Do forceCastToUInt32 and forceCastToFloat still serve a purpose? #49787

Closed
SingleAccretion opened this issue Mar 17, 2021 · 3 comments
Closed
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI untriaged New issue has not been triaged by the area owner

Comments

@SingleAccretion
Copy link
Contributor

The two functions in compiler.hpp are used sparsely (~20 uses between the two of them) throughout the Jit for performing the specified conversions. The comments on them, however, indicate they may be working around problems in compilers from over 15 years ago:

// Enforce float narrowing for buggy compilers (notably preWhidbey VC)
inline float forceCastToFloat(double d)
{
    Volatile<float> f = (float)d;
    return f;
}

// Enforce UInt32 narrowing for buggy compilers (notably Whidbey Beta 2 LKG)
inline UINT32 forceCastToUInt32(double d)
{
    Volatile<UINT32> u = (UINT32)d;
    return u;
}

I am thus wondering if those could be safely deleted and the normal C++ casts used instead.

Note that we may still want some casting indirection layer, for unified behavior across platforms. It is unclear to me if deleting these functions will make it harder to introduce this layer.

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Mar 17, 2021
@jkotas jkotas added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Mar 18, 2021
@EgorBo
Copy link
Member

EgorBo commented Mar 18, 2021

I wanted recently to add an edge case to one of those for MSVC 32 bit

image

@SingleAccretion
Copy link
Contributor Author

Yes...

After thinking a bit more about this, this issue is just a subset of (and is blocked by) #47478. Closing as not actionable.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 17, 2021
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 untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

3 participants