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

JIT: Fix generating unrepresentable nullchecks on ARM64 #71687

Merged
merged 5 commits into from
Jul 6, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revise
  • Loading branch information
jakobbotsch committed Jul 6, 2022
commit 7d3dfc6c35480aba8ef56f8908ac995c974d5345
12 changes: 8 additions & 4 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9965,25 +9965,29 @@ bool Compiler::lvaIsOSRLocal(unsigned varNum)
}

//------------------------------------------------------------------------------
// gtTypeForNullCheck: helper to get the most optimal and correct type for nullcheck
// gtTypeForNullCheck: helper to get the most optimal type for nullcheck
//
// Arguments:
// tree - the node for nullcheck;
//
var_types Compiler::gtTypeForNullCheck(GenTree* tree)
{
if (varTypeIsArithmetic(tree))
static const var_types s_typesBySize[] = { TYP_UNDEF, TYP_BYTE, TYP_SHORT, TYP_UNDEF, TYP_INT, TYP_UNDEF, TYP_UNDEF, TYP_UNDEF, TYP_LONG };

if (varTypeIsStruct(tree))
{
#if defined(TARGET_XARCH)
// Just an optimization for XARCH - smaller mov
if (varTypeIsLong(tree))
if (genTypeSize(tree) == 8)
{
return TYP_INT;
}
#endif

return tree->TypeGet();
assert((genTypeSize(tree) < ARRAY_SIZE(s_typesBySize)) && (s_typesBySize[genTypeSize(tree)] != TYP_UNDEF));
return s_typesBySize[genTypeSize(tree)];
}

// for the rest: probe a single byte to avoid potential AVEs
return TYP_BYTE;
}
Expand Down