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
Have Unsafe.Subtract and Unsafe.SubtractByteOffset be intrinsic
  • Loading branch information
tannergooding committed May 1, 2022
commit 2301adc9e44145a11ce5184e3146f7df7d3afdcc
39 changes: 35 additions & 4 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4834,8 +4834,8 @@ GenTree* Compiler::impSRCSUnsafeIntrinsic(NamedIntrinsic intrinsic,
tmp = op2;
}

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

case NI_SRCS_UNSAFE_AddByteOffset:
Expand Down Expand Up @@ -5136,7 +5136,33 @@ GenTree* Compiler::impSRCSUnsafeIntrinsic(NamedIntrinsic intrinsic,
// sub
// ret

return nullptr;
GenTree* op2 = impPopStack().val;
GenTree* op1 = impPopStack().val;
impBashVarAddrsToI(op1, op2);

GenTree* tmp = nullptr;
var_types type = TYP_UNKNOWN;

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);
tmp = new (this, GT_CALL) GenTreeOp(GT_MUL, type, op2, size DEBUGARG(/* largeNode */ true));
}
else
{
tmp = op2;
}

type = impGetByRefResultType(GT_SUB, /* uns */ false, &op1, &tmp);
return gtNewOperNode(GT_SUB, type, op1, tmp);
}

case NI_SRCS_UNSAFE_SubtractByteOffset:
Expand All @@ -5148,7 +5174,12 @@ GenTree* Compiler::impSRCSUnsafeIntrinsic(NamedIntrinsic intrinsic,
// sub
// ret

return nullptr;
GenTree* op2 = impPopStack().val;
GenTree* op1 = impPopStack().val;
impBashVarAddrsToI(op1, op2);

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

case NI_SRCS_UNSAFE_Unbox:
Expand Down