Skip to content
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
8 changes: 4 additions & 4 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1121,20 +1121,20 @@ AssertionIndex Compiler::optCreateAssertion(GenTree* op1,
//
// Set op1 to the instance pointer of the indirection
//
op1 = op1->gtEffectiveVal(/* commaOnly */ true);
op1 = op1->gtEffectiveVal();

ssize_t offset = 0;
while ((op1->gtOper == GT_ADD) && (op1->gtType == TYP_BYREF))
{
if (op1->gtGetOp2()->IsCnsIntOrI())
{
offset += op1->gtGetOp2()->AsIntCon()->gtIconVal;
op1 = op1->gtGetOp1()->gtEffectiveVal(/* commaOnly */ true);
op1 = op1->gtGetOp1()->gtEffectiveVal();
}
else if (op1->gtGetOp1()->IsCnsIntOrI())
{
offset += op1->gtGetOp1()->AsIntCon()->gtIconVal;
op1 = op1->gtGetOp2()->gtEffectiveVal(/* commaOnly */ true);
op1 = op1->gtGetOp2()->gtEffectiveVal();
}
else
{
Expand Down Expand Up @@ -4533,7 +4533,7 @@ bool Compiler::optAssertionIsNonNull(GenTree* op,
return true;
}

op = op->gtEffectiveVal(/* commaOnly */ true);
op = op->gtEffectiveVal();

if (!op->OperIs(GT_LCL_VAR))
{
Expand Down
10 changes: 0 additions & 10 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,11 +1262,6 @@ bool CodeGen::genCreateAddrMode(
break;
#endif // !TARGET_ARMARCH && !TARGET_LOONGARCH64 && !TARGET_RISCV64

case GT_NOP:

op1 = op1->AsOp()->gtOp1;
goto AGAIN;

case GT_COMMA:

op1 = op1->AsOp()->gtOp2;
Expand Down Expand Up @@ -1341,11 +1336,6 @@ bool CodeGen::genCreateAddrMode(
break;
#endif // TARGET_ARMARCH || TARGET_LOONGARCH64 || TARGET_RISCV64

case GT_NOP:

op2 = op2->AsOp()->gtOp1;
goto AGAIN;

case GT_COMMA:

op2 = op2->AsOp()->gtOp2;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -11397,6 +11397,7 @@ class GenTreeVisitor
case GT_PINVOKE_PROLOG:
case GT_PINVOKE_EPILOG:
case GT_IL_OFFSET:
case GT_NOP:
break;

// Lclvar unary operators
Expand Down Expand Up @@ -11437,7 +11438,6 @@ class GenTreeVisitor
case GT_PUTARG_REG:
case GT_PUTARG_STK:
case GT_RETURNTRAP:
case GT_NOP:
case GT_FIELD_ADDR:
case GT_RETURN:
case GT_RETFILT:
Expand Down
11 changes: 4 additions & 7 deletions src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ inline GenTree* Compiler::gtNewOperNode(genTreeOps oper, var_types type, GenTree
assert((GenTree::OperKind(oper) & (GTK_UNOP | GTK_BINOP)) != 0);
assert((GenTree::OperKind(oper) & GTK_EXOP) ==
0); // Can't use this to construct any types that extend unary/binary operator.
assert(op1 != nullptr || oper == GT_RETFILT || oper == GT_NOP || (oper == GT_RETURN && type == TYP_VOID));
assert(op1 != nullptr || oper == GT_RETFILT || (oper == GT_RETURN && type == TYP_VOID));

GenTree* node = new (this, oper) GenTreeOp(oper, type, op1, nullptr);

Expand Down Expand Up @@ -1602,7 +1602,7 @@ inline GenTree* Compiler::gtNewNullCheck(GenTree* addr, BasicBlock* basicBlock)

inline GenTree* Compiler::gtNewNothingNode()
{
return new (this, GT_NOP) GenTreeOp(GT_NOP, TYP_VOID);
return new (this, GT_NOP) GenTree(GT_NOP, TYP_VOID);
}
/*****************************************************************************/

Expand All @@ -1620,10 +1620,7 @@ inline bool GenTree::IsNothingNode() const
inline void GenTree::gtBashToNOP()
{
ChangeOper(GT_NOP);

gtType = TYP_VOID;
AsOp()->gtOp1 = AsOp()->gtOp2 = nullptr;

gtType = TYP_VOID;
gtFlags &= ~(GTF_ALL_EFFECT | GTF_REVERSE_OPS);
}

Expand Down Expand Up @@ -4415,10 +4412,10 @@ void GenTree::VisitOperands(TVisitor visitor)
case GT_PINVOKE_PROLOG:
case GT_PINVOKE_EPILOG:
case GT_IL_OFFSET:
case GT_NOP:
return;

// Unary operators with an optional operand
case GT_NOP:
case GT_FIELD_ADDR:
case GT_RETURN:
case GT_RETFILT:
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/jit/earlyprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,7 @@ GenTree* Compiler::optFindNullCheckToFold(GenTree* tree, LocalNumberToNullCheckT
return nullptr;
}

const bool commaOnly = true;
GenTree* commaOp1EffectiveValue = defValue->gtGetOp1()->gtEffectiveVal(commaOnly);
GenTree* commaOp1EffectiveValue = defValue->gtGetOp1()->gtEffectiveVal();

if (commaOp1EffectiveValue->OperGet() != GT_NULLCHECK)
{
Expand Down
24 changes: 15 additions & 9 deletions src/coreclr/jit/fgdiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2567,19 +2567,20 @@ Compiler::fgWalkResult Compiler::fgStress64RsltMulCB(GenTree** pTree, fgWalkData
return WALK_CONTINUE;
}

JITDUMP("STRESS_64RSLT_MUL before:\n");
DISPTREE(tree);
JITDUMP("STRESS_64RSLT_MUL before:\n")
DISPTREE(tree)

// To ensure optNarrowTree() doesn't fold back to the original tree.
tree->AsOp()->gtOp1 = pComp->gtNewCastNode(TYP_LONG, tree->AsOp()->gtOp1, false, TYP_LONG);
tree->AsOp()->gtOp1 = pComp->gtNewOperNode(GT_NOP, TYP_LONG, tree->AsOp()->gtOp1);
tree->AsOp()->gtOp1 = pComp->gtNewCastNode(TYP_LONG, tree->AsOp()->gtOp1, false, TYP_LONG);
tree->AsOp()->gtOp2 = pComp->gtNewCastNode(TYP_LONG, tree->AsOp()->gtOp2, false, TYP_LONG);
tree->AsOp()->gtOp1 = pComp->gtNewCastNode(TYP_LONG, tree->gtGetOp1(), false, TYP_LONG);
tree->AsOp()->gtOp2 = pComp->gtNewCastNode(TYP_LONG, tree->gtGetOp2(), false, TYP_LONG);
tree->gtType = TYP_LONG;
*pTree = pComp->gtNewCastNode(TYP_INT, tree, false, TYP_INT);

JITDUMP("STRESS_64RSLT_MUL after:\n");
DISPTREE(*pTree);
// To ensure optNarrowTree() doesn't fold back to the original tree.
tree->gtGetOp1()->gtDebugFlags |= GTF_DEBUG_CAST_DONT_FOLD;
tree->gtGetOp2()->gtDebugFlags |= GTF_DEBUG_CAST_DONT_FOLD;

JITDUMP("STRESS_64RSLT_MUL after:\n")
DISPTREE(*pTree)

return WALK_SKIP_SUBTREES;
}
Expand Down Expand Up @@ -3246,6 +3247,11 @@ void Compiler::fgDebugCheckTypes(GenTree* tree)
assert(!"TYP_ULONG and TYP_UINT are not legal in IR");
}

if (node->OperIs(GT_NOP))
{
assert(node->TypeIs(TYP_VOID) && "GT_NOP should be TYP_VOID.");
}

if (varTypeIsSmall(node))
{
if (node->OperIs(GT_COMMA))
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/fginline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class SubstitutePlaceholdersAndDevirtualizeWalker : public GenTreeVisitor<Substi

if (value->OperGet() == GT_COMMA)
{
GenTree* effectiveValue = value->gtEffectiveVal(/*commaOnly*/ true);
GenTree* effectiveValue = value->gtEffectiveVal();

noway_assert(
!varTypeIsStruct(effectiveValue) || (effectiveValue->OperGet() != GT_RET_EXPR) ||
Expand Down
34 changes: 16 additions & 18 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2763,6 +2763,7 @@ bool GenTree::Compare(GenTree* op1, GenTree* op2, bool swapOK)
}
return true;

case GT_NOP:
case GT_LABEL:
return true;

Expand Down Expand Up @@ -4512,7 +4513,7 @@ bool Compiler::gtCanSwapOrder(GenTree* firstNode, GenTree* secondNode)
bool Compiler::gtMarkAddrMode(GenTree* addr, int* pCostEx, int* pCostSz, var_types type)
{
GenTree* addrComma = addr;
addr = addr->gtEffectiveVal(/* commaOnly */ true);
addr = addr->gtEffectiveVal();

// These are "out" parameters on the call to genCreateAddrMode():
bool rev; // This will be true if the operands will need to be reversed. At this point we
Expand Down Expand Up @@ -5334,6 +5335,12 @@ unsigned Compiler::gtSetEvalOrder(GenTree* tree)
costSz = 0;
break;

case GT_NOP:
level = 0;
costEx = 0;
costSz = 0;
break;

default:
level = 1;
costEx = 1;
Expand Down Expand Up @@ -5449,11 +5456,6 @@ unsigned Compiler::gtSetEvalOrder(GenTree* tree)

break;

case GT_NOP:
costEx = 0;
costSz = 0;
break;

case GT_INTRINSIC:
intrinsic = tree->AsIntrinsic();
// named intrinsic
Expand Down Expand Up @@ -6444,6 +6446,7 @@ bool GenTree::TryGetUse(GenTree* operand, GenTree*** pUse)
case GT_PINVOKE_PROLOG:
case GT_PINVOKE_EPILOG:
case GT_IL_OFFSET:
case GT_NOP:
return false;

// Standard unary operators
Expand Down Expand Up @@ -6473,7 +6476,6 @@ bool GenTree::TryGetUse(GenTree* operand, GenTree*** pUse)
case GT_PUTARG_REG:
case GT_PUTARG_STK:
case GT_RETURNTRAP:
case GT_NOP:
case GT_RETURN:
case GT_RETFILT:
case GT_BSWAP:
Expand Down Expand Up @@ -8641,8 +8643,8 @@ bool GenTreeOp::UsesDivideByConstOptimized(Compiler* comp)
#endif // TARGET_ARM64

bool isSignedDivide = OperIs(GT_DIV, GT_MOD);
GenTree* dividend = gtGetOp1()->gtEffectiveVal(/*commaOnly*/ true);
GenTree* divisor = gtGetOp2()->gtEffectiveVal(/*commaOnly*/ true);
GenTree* dividend = gtGetOp1()->gtEffectiveVal();
GenTree* divisor = gtGetOp2()->gtEffectiveVal();

#if !defined(TARGET_64BIT)
if (dividend->OperIs(GT_LONG))
Expand Down Expand Up @@ -8764,7 +8766,7 @@ void GenTreeOp::CheckDivideByConstOptimized(Compiler* comp)
{
// Now set DONT_CSE on the GT_CNS_INT divisor, note that
// with ValueNumbering we can have a non GT_CNS_INT divisor
GenTree* divisor = gtGetOp2()->gtEffectiveVal(/*commaOnly*/ true);
GenTree* divisor = gtGetOp2()->gtEffectiveVal();
if (divisor->OperIs(GT_CNS_INT))
{
divisor->gtFlags |= GTF_DONT_CSE;
Expand Down Expand Up @@ -9211,6 +9213,7 @@ GenTree* Compiler::gtCloneExpr(

case GT_CATCH_ARG:
case GT_NO_OP:
case GT_NOP:
case GT_LABEL:
copy = new (this, oper) GenTree(oper, tree->gtType);
goto DONE;
Expand Down Expand Up @@ -10099,6 +10102,7 @@ GenTreeUseEdgeIterator::GenTreeUseEdgeIterator(GenTree* node)
case GT_PINVOKE_PROLOG:
case GT_PINVOKE_EPILOG:
case GT_IL_OFFSET:
case GT_NOP:
m_state = -1;
return;

Expand Down Expand Up @@ -10142,7 +10146,6 @@ GenTreeUseEdgeIterator::GenTreeUseEdgeIterator(GenTree* node)
return;

// Unary operators with an optional operand
case GT_NOP:
case GT_FIELD_ADDR:
case GT_RETURN:
case GT_RETFILT:
Expand Down Expand Up @@ -12126,6 +12129,7 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack)

// Vanilla leaves. No qualifying information available. So do nothing

case GT_NOP:
case GT_NO_OP:
case GT_START_NONGC:
case GT_START_PREEMPTGC:
Expand Down Expand Up @@ -14012,12 +14016,6 @@ CORINFO_CLASS_HANDLE Compiler::gtGetHelperArgClassHandle(GenTree* tree)
{
CORINFO_CLASS_HANDLE result = NO_CLASS_HANDLE;

// Walk through any wrapping nop.
if ((tree->gtOper == GT_NOP) && (tree->gtType == TYP_I_IMPL))
{
tree = tree->AsOp()->gtOp1;
}

// The handle could be a literal constant
if ((tree->OperGet() == GT_CNS_INT) && (tree->TypeGet() == TYP_I_IMPL))
{
Expand Down Expand Up @@ -18239,7 +18237,7 @@ CORINFO_CLASS_HANDLE Compiler::gtGetClassHandle(GenTree* tree, bool* pIsExact, b
}

// Tunnel through commas.
GenTree* obj = tree->gtEffectiveVal(false);
GenTree* obj = tree->gtEffectiveVal();
const genTreeOps objOp = obj->OperGet();

switch (objOp)
Expand Down
16 changes: 6 additions & 10 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ enum GenTreeDebugFlags : unsigned int
GTF_DEBUG_NODE_MASK = 0x0000003F, // These flags are all node (rather than operation) properties.

GTF_DEBUG_VAR_CSE_REF = 0x00800000, // GT_LCL_VAR -- This is a CSE LCL_VAR node
GTF_DEBUG_CAST_DONT_FOLD = 0x00400000, // GT_CAST -- Try to prevent this cast from being folded
};

inline constexpr GenTreeDebugFlags operator ~(GenTreeDebugFlags a)
Expand Down Expand Up @@ -1723,7 +1724,6 @@ struct GenTree
{
case GT_LEA:
case GT_RETFILT:
case GT_NOP:
case GT_FIELD_ADDR:
return true;
case GT_RETURN:
Expand Down Expand Up @@ -1816,7 +1816,7 @@ struct GenTree

void ReplaceOperand(GenTree** useEdge, GenTree* replacement);

inline GenTree* gtEffectiveVal(bool commaOnly = false);
inline GenTree* gtEffectiveVal();

inline GenTree* gtCommaStoreVal();

Expand Down Expand Up @@ -2995,7 +2995,7 @@ struct GenTreeOp : public GenTreeUnOp
: GenTreeUnOp(oper, type DEBUGARG(largeNode)), gtOp2(nullptr)
{
// Unary operators with optional arguments:
assert(oper == GT_NOP || oper == GT_RETURN || oper == GT_RETFILT || OperIsBlk(oper));
assert(oper == GT_RETURN || oper == GT_RETFILT || OperIsBlk(oper));
}

// returns true if we will use the division by constant optimization for this node.
Expand Down Expand Up @@ -9239,18 +9239,14 @@ inline GenTree*& GenTree::Data()
return OperIsLocalStore() ? AsLclVarCommon()->Data() : AsIndir()->Data();
}

inline GenTree* GenTree::gtEffectiveVal(bool commaOnly /* = false */)
inline GenTree* GenTree::gtEffectiveVal()
{
GenTree* effectiveVal = this;
while (true)
{
if (effectiveVal->gtOper == GT_COMMA)
if (effectiveVal->OperIs(GT_COMMA))
{
effectiveVal = effectiveVal->AsOp()->gtGetOp2();
}
else if (!commaOnly && (effectiveVal->gtOper == GT_NOP) && (effectiveVal->AsOp()->gtOp1 != nullptr))
{
effectiveVal = effectiveVal->AsOp()->gtOp1;
effectiveVal = effectiveVal->gtGetOp2();
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/gtlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ GTNODE(CNS_VEC , GenTreeVecCon ,0,0,GTK_LEAF)
//-----------------------------------------------------------------------------

GTNODE(NOT , GenTreeOp ,0,0,GTK_UNOP)
GTNODE(NOP , GenTree ,0,0,GTK_UNOP|DBK_NOCONTAIN)
GTNODE(NOP , GenTree ,0,1,GTK_LEAF|DBK_NOCONTAIN)
GTNODE(NEG , GenTreeOp ,0,0,GTK_UNOP)

GTNODE(INTRINSIC , GenTreeIntrinsic ,0,0,GTK_BINOP|GTK_EXOP)
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/jit/ifconversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,6 @@ bool OptIfConversionDsc::IfConvertCheckStmts(BasicBlock* fromBlock, IfConvertOpe

// These do not need conditional execution.
case GT_NOP:
if (tree->gtGetOp1() != nullptr || (tree->gtFlags & (GTF_SIDE_EFFECT | GTF_ORDER_SIDEEFF)) != 0)
{
return false;
}
break;

// Cannot optimise this block.
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6875,7 +6875,7 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call,
// See what we know about the type of 'this' in the call.
assert(call->gtArgs.HasThisPointer());
CallArg* thisArg = call->gtArgs.GetThisArg();
GenTree* thisObj = thisArg->GetEarlyNode()->gtEffectiveVal(false);
GenTree* thisObj = thisArg->GetEarlyNode()->gtEffectiveVal();
bool isExact = false;
bool objIsNonNull = false;
CORINFO_CLASS_HANDLE objClass = gtGetClassHandle(thisObj, &isExact, &objIsNonNull);
Expand Down
Loading