Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b30794d
Treat System.Runtime.CompilerServices.Unsafe as intrinsic
tannergooding May 1, 2022
a9bc307
Remove duplicated logic from Get_CORINFO_SIG_INFO
tannergooding May 1, 2022
3e3c839
Don't create a multiply node if the size is 1
tannergooding May 1, 2022
9e84bdd
Remove unnecessary impBashVarAddrsToI calls over gtNewIconNode
tannergooding May 1, 2022
4d42990
Use `#ifdef TARGET_64BIT` rather than `#if (REGSIZE_BYTES == 8)`
tannergooding May 1, 2022
201217e
Don't unnecessarily call `genActualType(TYP_U_IMPL)`, just use `TYP_I…
tannergooding May 1, 2022
1bf3f3a
Only insert casts for `TYP_INT` to `TYP_I_IMPL` or `TYP_U_IMPL` on 64…
tannergooding May 1, 2022
6963037
Have Unsafe.SkipInit create a `GT_NO_OP` node
tannergooding May 1, 2022
2301adc
Have Unsafe.Subtract and Unsafe.SubtractByteOffset be intrinsic
tannergooding May 1, 2022
3c4f660
Adding a couple `CLANG_FORMAT_COMMENT_ANCHOR;` to comments that prece…
tannergooding May 1, 2022
4d91472
Applying formatting patch
tannergooding May 1, 2022
982660e
Revert "Have Unsafe.Subtract and Unsafe.SubtractByteOffset be intrinsic"
tannergooding May 1, 2022
a933fec
Fixing the operand evaluation order for NI_SRCS_UNSAFE_Add
tannergooding May 2, 2022
fff8ddc
Fixing the operand evaluation order for NI_SRCS_UNSAFE_ByteOffset
tannergooding May 2, 2022
7166b2e
Implement NI_SRCS_UNSAFE_SubtractByteOffset
tannergooding May 2, 2022
4e3303a
Fix the build failure
tannergooding May 2, 2022
66de257
Ensure impImplicitIorI4Cast is called on op2 for NI_SRCS_UNSAFE_Add
tannergooding May 2, 2022
e491b78
Don't declare a `tmp` in NI_SRCS_UNSAFE_Add to make the logic clearer
tannergooding May 2, 2022
b3e6e3c
Have NI_SRCS_UNSAFE_SkipInit return gtNewNothingNode
tannergooding May 2, 2022
0b372a5
Handle side effects for NI_SRCS_UNSAFE_SkipInit
tannergooding May 2, 2022
3e2a2ae
Revert "Implement NI_SRCS_UNSAFE_SubtractByteOffset"
tannergooding May 2, 2022
ab91385
Manually simplify some of the NI_SRCS_* import logic
tannergooding May 2, 2022
f8dd74d
Ensure NI_SRCS_SkipInit returns the unused node when its side-effecting
tannergooding May 2, 2022
77b9af1
Remove unnecessary comment anchors
tannergooding May 2, 2022
d7b4783
Applying formatting patch
tannergooding May 2, 2022
0c07847
Try to workaround the JIT issue by spilling op1/op2 for Unsafe.Add
tannergooding May 3, 2022
272bce2
Apply formatting patch
tannergooding May 3, 2022
8c964f1
Merge remote-tracking branch 'dotnet/main' into unsafe-intrinsics
tannergooding May 5, 2022
79c717b
Revert "Try to workaround the JIT issue by spilling op1/op2 for Unsaf…
tannergooding May 5, 2022
e573dd8
Have Unsafe.Subtract and Unsafe.SubtractByteOffset be intrinsic
tannergooding May 5, 2022
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
Manually simplify some of the NI_SRCS_* import logic
  • Loading branch information
tannergooding committed May 2, 2022
commit ab91385ad04264649461109a6c64e8aa5f16ef12
55 changes: 9 additions & 46 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4815,22 +4815,15 @@ GenTree* Compiler::impSRCSUnsafeIntrinsic(NamedIntrinsic intrinsic,

op2 = impImplicitIorI4Cast(op2, TYP_I_IMPL);

var_types type = TYP_UNKNOWN;
unsigned classSize = info.compCompHnd->getClassSize(sig->sigInst.methInst[0]);
unsigned classSize = info.compCompHnd->getClassSize(sig->sigInst.methInst[0]);

if (classSize != 1)
{
GenTree* size = gtNewIconNode(classSize, TYP_INT);

#ifdef TARGET_64BIT
size = gtNewCastNode(TYP_I_IMPL, size, /* uns */ false, TYP_I_IMPL);
#endif

type = impGetByRefResultType(GT_MUL, /* uns */ false, &op2, &size);
op2 = new (this, GT_CALL) GenTreeOp(GT_MUL, type, op2, size DEBUGARG(/* largeNode */ true));
GenTree* size = gtNewIconNode(classSize, TYP_I_IMPL);
op2 = gtNewOperNode(GT_MUL, TYP_I_IMPL, op2, size);
}

type = impGetByRefResultType(GT_ADD, /* uns */ false, &op1, &op2);
var_types type = impGetByRefResultType(GT_ADD, /* uns */ false, &op1, &op2);
return gtNewOperNode(GT_ADD, type, op1, op2);
}

Expand Down Expand Up @@ -4886,16 +4879,10 @@ GenTree* Compiler::impSRCSUnsafeIntrinsic(NamedIntrinsic intrinsic,
// ret
CLANG_FORMAT_COMMENT_ANCHOR;

#ifdef TARGET_64BIT
bool uns = true;
#else
bool uns = false;
#endif

GenTree* op1 = impPopStack().val;
impBashVarAddrsToI(op1);

return gtNewCastNode(TYP_I_IMPL, op1, uns, TYP_U_IMPL);
return gtNewCastNode(TYP_I_IMPL, op1, /* uns */ false, TYP_I_IMPL);
}

case NI_SRCS_UNSAFE_AsRef:
Expand Down Expand Up @@ -5012,7 +4999,7 @@ GenTree* Compiler::impSRCSUnsafeIntrinsic(NamedIntrinsic intrinsic,
GenTree* op1 = impPopStack().val;

GenTree* tmp = gtNewOperNode(GT_GT, TYP_INT, op1, op2);
tmp->gtFlags |= GTF_RELOP_NAN_UN | GTF_UNSIGNED;
tmp->gtFlags |= GTF_UNSIGNED;
return gtFoldExpr(tmp);
}

Expand All @@ -5029,7 +5016,7 @@ GenTree* Compiler::impSRCSUnsafeIntrinsic(NamedIntrinsic intrinsic,
GenTree* op1 = impPopStack().val;

GenTree* tmp = gtNewOperNode(GT_LT, TYP_INT, op1, op2);
tmp->gtFlags |= GTF_RELOP_NAN_UN | GTF_UNSIGNED;
tmp->gtFlags |= GTF_UNSIGNED;
return gtFoldExpr(tmp);
}

Expand All @@ -5044,20 +5031,8 @@ GenTree* Compiler::impSRCSUnsafeIntrinsic(NamedIntrinsic intrinsic,
// ret
CLANG_FORMAT_COMMENT_ANCHOR;

#ifdef TARGET_64BIT
bool uns = true;
#else
bool uns = false;
#endif

GenTree* op1 = impPopStack().val;

GenTree* cns = gtNewIconNode(0, TYP_INT);

#ifdef TARGET_64BIT
cns = gtNewCastNode(TYP_I_IMPL, cns, uns, TYP_U_IMPL);
#endif

GenTree* cns = gtNewIconNode(0, TYP_BYREF);
GenTree* tmp = gtNewOperNode(GT_EQ, TYP_INT, op1, cns);
return gtFoldExpr(tmp);
}
Expand All @@ -5071,19 +5046,7 @@ GenTree* Compiler::impSRCSUnsafeIntrinsic(NamedIntrinsic intrinsic,
// ret
CLANG_FORMAT_COMMENT_ANCHOR;

#ifdef TARGET_64BIT
bool uns = true;
#else
bool uns = false;
#endif

GenTree* cns = gtNewIconNode(0, TYP_INT);

#ifdef TARGET_64BIT
cns = gtNewCastNode(TYP_I_IMPL, cns, uns, TYP_U_IMPL);
#endif

return cns;
return gtNewIconNode(0, TYP_BYREF);
}

case NI_SRCS_UNSAFE_Read:
Expand Down