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

Delete GT_SIMD_CHK and GT_HW_INTRINSIC_CHK #62088

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 7 additions & 8 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ AssertionIndex Compiler::optCreateAssertion(GenTree* op1,
AssertionDsc assertion = {OAK_INVALID};
assert(assertion.assertionKind == OAK_INVALID);

if (op1->gtOper == GT_ARR_BOUNDS_CHECK)
if (op1->OperIs(GT_BOUNDS_CHECK))
{
if (assertionKind == OAK_NO_THROW)
{
Expand Down Expand Up @@ -2583,7 +2583,7 @@ void Compiler::optAssertionGen(GenTree* tree)
assertionInfo = optCreateAssertion(tree->AsArrLen()->ArrRef(), nullptr, OAK_NOT_EQUAL);
break;

case GT_ARR_BOUNDS_CHECK:
case GT_BOUNDS_CHECK:
if (!optLocalAssertionProp)
{
assertionInfo = optCreateAssertion(tree, nullptr, OAK_NO_THROW);
Expand Down Expand Up @@ -4053,8 +4053,7 @@ GenTree* Compiler::optAssertionProp_Comma(ASSERT_VALARG_TP assertions, GenTree*
{
// Remove the bounds check as part of the GT_COMMA node since we need parent pointer to remove nodes.
// When processing visits the bounds check, it sets the throw kind to None if the check is redundant.
if ((tree->gtGetOp1()->OperGet() == GT_ARR_BOUNDS_CHECK) &&
((tree->gtGetOp1()->gtFlags & GTF_ARR_BOUND_INBND) != 0))
if (tree->gtGetOp1()->OperIs(GT_BOUNDS_CHECK) && ((tree->gtGetOp1()->gtFlags & GTF_CHK_INDEX_INBND) != 0))
{
optRemoveCommaBasedRangeCheck(tree, stmt);
return optAssertionProp_Update(tree, tree, stmt);
Expand Down Expand Up @@ -4391,7 +4390,7 @@ GenTree* Compiler::optAssertionProp_BndsChk(ASSERT_VALARG_TP assertions, GenTree
return nullptr;
}

assert(tree->gtOper == GT_ARR_BOUNDS_CHECK);
assert(tree->OperIs(GT_BOUNDS_CHECK));

#ifdef FEATURE_ENABLE_NO_RANGE_CHECKS
if (JitConfig.JitNoRangeChks())
Expand All @@ -4403,7 +4402,7 @@ GenTree* Compiler::optAssertionProp_BndsChk(ASSERT_VALARG_TP assertions, GenTree
gtDispTree(tree, nullptr, nullptr, true);
}
#endif // DEBUG
tree->gtFlags |= GTF_ARR_BOUND_INBND;
tree->gtFlags |= GTF_CHK_INDEX_INBND;
return nullptr;
}
#endif // FEATURE_ENABLE_NO_RANGE_CHECKS
Expand Down Expand Up @@ -4514,7 +4513,7 @@ GenTree* Compiler::optAssertionProp_BndsChk(ASSERT_VALARG_TP assertions, GenTree

// Defer actually removing the tree until processing reaches its parent comma, since
// optRemoveCommaBasedRangeCheck needs to rewrite the whole comma tree.
arrBndsChk->gtFlags |= GTF_ARR_BOUND_INBND;
arrBndsChk->gtFlags |= GTF_CHK_INDEX_INBND;

return nullptr;
}
Expand Down Expand Up @@ -4610,7 +4609,7 @@ GenTree* Compiler::optAssertionProp(ASSERT_VALARG_TP assertions, GenTree* tree,
case GT_NULLCHECK:
return optAssertionProp_Ind(assertions, tree, stmt);

case GT_ARR_BOUNDS_CHECK:
case GT_BOUNDS_CHECK:
return optAssertionProp_BndsChk(assertions, tree, stmt);

case GT_COMMA:
Expand Down
12 changes: 3 additions & 9 deletions src/coreclr/jit/codegenarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,7 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode)
instGen(INS_nop);
break;

case GT_ARR_BOUNDS_CHECK:
#ifdef FEATURE_SIMD
case GT_SIMD_CHK:
#endif // FEATURE_SIMD
#ifdef FEATURE_HW_INTRINSICS
case GT_HW_INTRINSIC_CHK:
#endif // FEATURE_HW_INTRINSICS
case GT_BOUNDS_CHECK:
genRangeCheck(treeNode);
break;

Expand Down Expand Up @@ -1418,11 +1412,11 @@ void CodeGen::genMultiRegStoreToSIMDLocal(GenTreeLclVar* lclNode)
#endif // FEATURE_SIMD

//------------------------------------------------------------------------
// genRangeCheck: generate code for GT_ARR_BOUNDS_CHECK node.
// genRangeCheck: generate code for GT_BOUNDS_CHECK node.
//
void CodeGen::genRangeCheck(GenTree* oper)
{
noway_assert(oper->OperIsBoundsCheck());
noway_assert(oper->OperIs(GT_BOUNDS_CHECK));
GenTreeBoundsChk* bndsChk = oper->AsBoundsChk();

GenTree* arrLen = bndsChk->GetArrayLength();
Expand Down
10 changes: 2 additions & 8 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1742,13 +1742,7 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode)
GetEmitter()->emitIns_Nop(1);
break;

case GT_ARR_BOUNDS_CHECK:
#ifdef FEATURE_SIMD
case GT_SIMD_CHK:
#endif // FEATURE_SIMD
#ifdef FEATURE_HW_INTRINSICS
case GT_HW_INTRINSIC_CHK:
#endif // FEATURE_HW_INTRINSICS
case GT_BOUNDS_CHECK:
genRangeCheck(treeNode);
break;

Expand Down Expand Up @@ -3864,7 +3858,7 @@ void CodeGen::genCodeForCmpXchg(GenTreeCmpXchg* tree)
// generate code for BoundsCheck nodes
void CodeGen::genRangeCheck(GenTree* oper)
{
noway_assert(oper->OperIsBoundsCheck());
noway_assert(oper->OperIs(GT_BOUNDS_CHECK));
GenTreeBoundsChk* bndsChk = oper->AsBoundsChk();

GenTree* arrIndex = bndsChk->GetIndex();
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/earlyprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,13 @@ GenTree* Compiler::optEarlyPropRewriteTree(GenTree* tree, LocalNumberToNullCheck
return nullptr;
}

// When replacing GT_ARR_LENGTH nodes with constants we can end up with GT_ARR_BOUNDS_CHECK
// When replacing GT_ARR_LENGTH nodes with constants we can end up with GT_BOUNDS_CHECK
// nodes that have constant operands and thus can be trivially proved to be useless. It's
// better to remove these range checks here, otherwise they'll pass through assertion prop
// (creating useless (c1 < c2)-like assertions) and reach RangeCheck where they are finally
// removed. Common patterns like new int[] { x, y, z } benefit from this.

if ((tree->gtNext != nullptr) && tree->gtNext->OperIs(GT_ARR_BOUNDS_CHECK))
if ((tree->gtNext != nullptr) && tree->gtNext->OperIs(GT_BOUNDS_CHECK))
{
GenTreeBoundsChk* check = tree->gtNext->AsBoundsChk();

Expand Down
12 changes: 3 additions & 9 deletions src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2940,7 +2940,7 @@ void Compiler::fgFindOperOrder()
// and computing lvaOutgoingArgSpaceSize.
//
// Notes:
// Lowers GT_ARR_LENGTH, GT_ARR_BOUNDS_CHECK, and GT_SIMD_CHK.
// Lowers GT_ARR_LENGTH, GT_BOUNDS_CHECK.
//
// For target ABIs with fixed out args area, computes upper bound on
// the size of this area from the calls in the IR.
Expand Down Expand Up @@ -3003,13 +3003,7 @@ void Compiler::fgSimpleLowering()
break;
}

case GT_ARR_BOUNDS_CHECK:
#ifdef FEATURE_SIMD
case GT_SIMD_CHK:
#endif // FEATURE_SIMD
#ifdef FEATURE_HW_INTRINSICS
case GT_HW_INTRINSIC_CHK:
#endif // FEATURE_HW_INTRINSICS
case GT_BOUNDS_CHECK:
{
// Add in a call to an error routine.
fgSetRngChkTarget(tree, false);
Expand Down Expand Up @@ -4479,7 +4473,7 @@ void Compiler::fgSetBlockOrder(BasicBlock* block)
}
break;

case GT_ARR_BOUNDS_CHECK:
case GT_BOUNDS_CHECK:
return Compiler::WALK_ABORT;

default:
Expand Down
109 changes: 36 additions & 73 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,43 +244,36 @@ void GenTree::InitNodeSize()
GenTree::s_gtNodeSizes[GT_RETURN] = TREE_NODE_SZ_LARGE;
}

GenTree::s_gtNodeSizes[GT_CALL] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_CAST] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_FTN_ADDR] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_BOX] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_INDEX] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_INDEX_ADDR] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_ARR_BOUNDS_CHECK] = TREE_NODE_SZ_SMALL;
#ifdef FEATURE_SIMD
GenTree::s_gtNodeSizes[GT_SIMD_CHK] = TREE_NODE_SZ_SMALL;
#endif // FEATURE_SIMD
#ifdef FEATURE_HW_INTRINSICS
GenTree::s_gtNodeSizes[GT_HW_INTRINSIC_CHK] = TREE_NODE_SZ_SMALL;
#endif // FEATURE_HW_INTRINSICS

GenTree::s_gtNodeSizes[GT_ARR_ELEM] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_ARR_INDEX] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_ARR_OFFSET] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_RET_EXPR] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_FIELD] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_CMPXCHG] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_QMARK] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_DYN_BLK] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_STORE_DYN_BLK] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_INTRINSIC] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_ALLOCOBJ] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_CALL] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_CAST] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_FTN_ADDR] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_BOX] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_INDEX] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_INDEX_ADDR] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_BOUNDS_CHECK] = TREE_NODE_SZ_SMALL;
GenTree::s_gtNodeSizes[GT_ARR_ELEM] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_ARR_INDEX] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_ARR_OFFSET] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_RET_EXPR] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_FIELD] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_CMPXCHG] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_QMARK] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_DYN_BLK] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_STORE_DYN_BLK] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_INTRINSIC] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_ALLOCOBJ] = TREE_NODE_SZ_LARGE;
#if USE_HELPERS_FOR_INT_DIV
GenTree::s_gtNodeSizes[GT_DIV] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_UDIV] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_MOD] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_UMOD] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_DIV] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_UDIV] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_MOD] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_UMOD] = TREE_NODE_SZ_LARGE;
#endif
#ifdef FEATURE_PUT_STRUCT_ARG_STK
// TODO-Throughput: This should not need to be a large node. The object info should be
// obtained from the child node.
GenTree::s_gtNodeSizes[GT_PUTARG_STK] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_PUTARG_STK] = TREE_NODE_SZ_LARGE;
#if FEATURE_ARG_SPLIT
GenTree::s_gtNodeSizes[GT_PUTARG_SPLIT] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_PUTARG_SPLIT] = TREE_NODE_SZ_LARGE;
#endif // FEATURE_ARG_SPLIT
#endif // FEATURE_PUT_STRUCT_ARG_STK

Expand Down Expand Up @@ -1483,13 +1476,7 @@ bool GenTree::Compare(GenTree* op1, GenTree* op2, bool swapOK)
return false;
}
break;
case GT_ARR_BOUNDS_CHECK:
#ifdef FEATURE_SIMD
case GT_SIMD_CHK:
#endif // FEATURE_SIMD
#ifdef FEATURE_HW_INTRINSICS
case GT_HW_INTRINSIC_CHK:
#endif // FEATURE_HW_INTRINSICS
case GT_BOUNDS_CHECK:
if (op1->AsBoundsChk()->gtThrowKind != op2->AsBoundsChk()->gtThrowKind)
{
return false;
Expand Down Expand Up @@ -1930,13 +1917,7 @@ unsigned Compiler::gtHashValue(GenTree* tree)
hash += static_cast<unsigned>(tree->AsAddrMode()->Offset() << 3) + tree->AsAddrMode()->gtScale;
break;

case GT_ARR_BOUNDS_CHECK:
#ifdef FEATURE_SIMD
case GT_SIMD_CHK:
#endif // FEATURE_SIMD
#ifdef FEATURE_HW_INTRINSICS
case GT_HW_INTRINSIC_CHK:
#endif // FEATURE_HW_INTRINSICS
case GT_BOUNDS_CHECK:
hash = genTreeHashAdd(hash, tree->AsBoundsChk()->gtThrowKind);
break;

Expand Down Expand Up @@ -4060,13 +4041,7 @@ unsigned Compiler::gtSetEvalOrder(GenTree* tree)
}
break;

case GT_ARR_BOUNDS_CHECK:
#ifdef FEATURE_SIMD
case GT_SIMD_CHK:
#endif
#ifdef FEATURE_HW_INTRINSICS
case GT_HW_INTRINSIC_CHK:
#endif
case GT_BOUNDS_CHECK:
costEx = 4; // cmp reg,reg and jae throw (not taken)
costSz = 7; // jump to cold section
break;
Expand Down Expand Up @@ -4331,7 +4306,7 @@ unsigned Compiler::gtSetEvalOrder(GenTree* tree)
// because of trickiness around ensuring the execution order does not change during rationalization.
tryToSwap = false;
}
else if (GenTree::OperIsBoundsCheck(oper))
else if (oper == GT_BOUNDS_CHECK)
{
// Bounds check nodes used to not be binary, thus GTF_REVERSE_OPS was
// not enabled for them. This condition preserves that behavior.
Expand Down Expand Up @@ -5404,17 +5379,11 @@ bool GenTree::OperMayThrow(Compiler* comp)
return false;
}

case GT_ARR_BOUNDS_CHECK:
case GT_BOUNDS_CHECK:
case GT_ARR_INDEX:
case GT_ARR_OFFSET:
case GT_LCLHEAP:
case GT_CKFINITE:
#ifdef FEATURE_SIMD
case GT_SIMD_CHK:
#endif // FEATURE_SIMD
#ifdef FEATURE_HW_INTRINSICS
case GT_HW_INTRINSIC_CHK:
#endif // FEATURE_HW_INTRINSICS
case GT_INDEX_ADDR:
return true;

Expand Down Expand Up @@ -7501,16 +7470,10 @@ GenTree* Compiler::gtCloneExpr(
#endif
break;

case GT_ARR_BOUNDS_CHECK:
#ifdef FEATURE_SIMD
case GT_SIMD_CHK:
#endif // FEATURE_SIMD
#ifdef FEATURE_HW_INTRINSICS
case GT_HW_INTRINSIC_CHK:
#endif // FEATURE_HW_INTRINSICS
copy = new (this, oper)
GenTreeBoundsChk(oper, tree->TypeGet(), tree->AsBoundsChk()->GetIndex(),
tree->AsBoundsChk()->GetArrayLength(), tree->AsBoundsChk()->gtThrowKind);
case GT_BOUNDS_CHECK:
copy = new (this, GT_BOUNDS_CHECK)
GenTreeBoundsChk(tree->AsBoundsChk()->GetIndex(), tree->AsBoundsChk()->GetArrayLength(),
tree->AsBoundsChk()->gtThrowKind);
copy->AsBoundsChk()->gtIndRngFailBB = tree->AsBoundsChk()->gtIndRngFailBB;
break;

Expand Down Expand Up @@ -9096,7 +9059,7 @@ void Compiler::gtDispNodeName(GenTree* tree)
}
bufp += SimpleSprintf_s(bufp, buf, sizeof(buf), "%d)", lea->Offset());
}
else if (tree->gtOper == GT_ARR_BOUNDS_CHECK)
else if (tree->gtOper == GT_BOUNDS_CHECK)
{
switch (tree->AsBoundsChk()->gtThrowKind)
{
Expand Down Expand Up @@ -13134,7 +13097,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree)

// This condition exists to preserve previous behavior.
// TODO-CQ: enable folding for bounds checks nodes.
if (tree->OperIsBoundsCheck())
if (tree->OperIs(GT_BOUNDS_CHECK))
{
return tree;
}
Expand Down Expand Up @@ -17355,7 +17318,7 @@ void GenTree::ParseArrayAddressWork(Compiler* comp,

case GT_COMMA:
// We don't care about exceptions for this purpose.
if ((AsOp()->gtOp1->OperGet() == GT_ARR_BOUNDS_CHECK) || AsOp()->gtOp1->IsNothingNode())
if (AsOp()->gtOp1->OperIs(GT_BOUNDS_CHECK) || AsOp()->gtOp1->IsNothingNode())
{
AsOp()->gtOp2->ParseArrayAddressWork(comp, inputMul, pArr, pInxVN, pOffset, pFldSeq);
return;
Expand Down
Loading