Skip to content

Commit

Permalink
Delete a bit of dead code (#77655)
Browse files Browse the repository at this point in the history
Mostly I was after the FP morphing, but removed some other things along the way as well.

No diffs except a nice TP boost as expected.
  • Loading branch information
SingleAccretion authored Nov 1, 2022
1 parent bd175da commit 3429533
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 117 deletions.
1 change: 0 additions & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5767,7 +5767,6 @@ class Compiler
GenTree* fgMorphBlockOperand(GenTree* tree, var_types asgType, ClassLayout* blockLayout, bool isBlkReqd);
GenTree* fgMorphCopyBlock(GenTree* tree);
GenTree* fgMorphStoreDynBlock(GenTreeStoreDynBlk* tree);
GenTree* fgMorphForRegisterFP(GenTree* tree);
GenTree* fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optAssertionPropDone = nullptr);
void fgTryReplaceStructLocalWithField(GenTree* tree);
GenTree* fgOptimizeCast(GenTreeCast* cast);
Expand Down
30 changes: 4 additions & 26 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15403,40 +15403,24 @@ GenTree* Compiler::gtNewTempAssign(
if (genActualType(valTyp) != genActualType(dstTyp))
{
// Plus some other exceptions that are apparently legal:
// 1) TYP_REF or BYREF = TYP_I_IMPL
// - TYP_REF or BYREF = TYP_I_IMPL
bool ok = false;
if (varTypeIsGC(dstTyp) && (valTyp == TYP_I_IMPL))
{
ok = true;
}
// 2) TYP_DOUBLE = TYP_FLOAT or TYP_FLOAT = TYP_DOUBLE
else if (varTypeIsFloating(dstTyp) && varTypeIsFloating(valTyp))
{
ok = true;
}
// 3) TYP_BYREF = TYP_REF when object stack allocation is enabled
// - TYP_BYREF = TYP_REF when object stack allocation is enabled
else if (JitConfig.JitObjectStackAllocation() && (dstTyp == TYP_BYREF) && (valTyp == TYP_REF))
{
ok = true;
}
else if (!varTypeIsGC(dstTyp) && (genTypeSize(valTyp) == genTypeSize(dstTyp)))
{
// We can have assignments that require a change of register file, e.g. for arguments
// and call returns. Lowering and Codegen will handle these.
ok = true;
}
else if ((dstTyp == TYP_STRUCT) && (valTyp == TYP_INT))
{
// It could come from `ASG(struct, 0)` that was propagated to `RETURN struct(0)`,
// and now it is merging to a struct again.
assert(tmp == genReturnLocal);
ok = true;
}
else if (varTypeIsSIMD(dstTyp) && (valTyp == TYP_STRUCT))
{
assert(val->IsCall());
ok = true;
}

if (!ok)
{
Expand Down Expand Up @@ -15466,7 +15450,6 @@ GenTree* Compiler::gtNewTempAssign(

GenTree* asg;
GenTree* dest = gtNewLclvNode(tmp, dstTyp);
dest->gtFlags |= GTF_VAR_DEF;

// With first-class structs, we should be propagating the class handle on all non-primitive
// struct types. We don't have a convenient way to do that for all SIMD temps, since some
Expand Down Expand Up @@ -15502,18 +15485,13 @@ GenTree* Compiler::gtNewTempAssign(
{
assert(valx->gtOper != GT_OBJ);
}
dest->gtFlags |= GTF_DONT_CSE;

valx->gtFlags |= GTF_DONT_CSE;
asg = impAssignStruct(dest, val, valStructHnd, CHECK_SPILL_NONE, pAfterStmt, di, block);
}
else
{
// We may have a scalar type variable assigned a struct value, e.g. a 'genReturnLocal'
// when the ABI calls for returning a struct as a primitive type.
// TODO-1stClassStructs: When we stop "lying" about the types for ABI purposes, the
// 'genReturnLocal' should be the original struct type.
assert(!varTypeIsStruct(valTyp) || ((valStructHnd != NO_CLASS_HANDLE) &&
(typGetObjLayout(valStructHnd)->GetSize() == genTypeSize(varDsc))));
assert(!varTypeIsStruct(valTyp));
asg = gtNewAssignNode(dest, val);
}

Expand Down
40 changes: 7 additions & 33 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,7 @@ GenTree* Compiler::impAssignStructPtr(GenTree* destAddr,
BasicBlock* block /* = NULL */
)
{
GenTree* dest = nullptr;
GenTreeFlags destFlags = GTF_EMPTY;
GenTree* dest = nullptr;

DebugInfo usedDI = di;
if (!usedDI.IsValid())
Expand Down Expand Up @@ -1351,9 +1350,6 @@ GenTree* Compiler::impAssignStructPtr(GenTree* destAddr,
lvaGetDesc(dest->AsLclVar())->lvIsMultiRegRet = true;
}

dest->gtFlags |= destFlags;
destFlags = dest->gtFlags;

// return an assignment node, to be appended
GenTree* asgNode = gtNewAssignNode(dest, src);
gtBlockOpInit(asgNode, dest, src, false);
Expand Down Expand Up @@ -5687,33 +5683,6 @@ void Compiler::impValidateMemoryAccessOpcode(const BYTE* codeAddr, const BYTE* c
}
}

/*****************************************************************************/

#ifdef DEBUG

#undef RETURN // undef contracts RETURN macro

enum controlFlow_t
{
NEXT,
CALL,
RETURN,
THROW,
BRANCH,
COND_BRANCH,
BREAK,
PHI,
META,
};

const static controlFlow_t controlFlow[] = {
#define OPDEF(c, s, pop, push, args, type, l, s1, s2, flow) flow,
#include "opcode.def"
#undef OPDEF
};

#endif // DEBUG

/*****************************************************************************
* Determine the result type of an arithmetic operation
* On 64-bit inserts upcasts when native int is mixed with int32
Expand Down Expand Up @@ -8068,8 +8037,13 @@ void Compiler::impImportBlockCode(BasicBlock* block)
assertImp(genActualType(op1) == genActualType(op2) || (varTypeIsI(op1) && varTypeIsI(op2)) ||
(varTypeIsFloating(op1) && varTypeIsFloating(op2)));

// Create the comparison node.
if ((op1->TypeGet() != op2->TypeGet()) && varTypeIsFloating(op1))
{
op1 = impImplicitR4orR8Cast(op1, TYP_DOUBLE);
op2 = impImplicitR4orR8Cast(op2, TYP_DOUBLE);
}

// Create the comparison node.
op1 = gtNewOperNode(oper, TYP_INT, op1, op2);

// TODO: setting both flags when only one is appropriate.
Expand Down
57 changes: 0 additions & 57 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9164,58 +9164,6 @@ GenTree* Compiler::fgMorphBlockOperand(GenTree* tree, var_types asgType, ClassLa
return effectiveVal;
}

// insert conversions and normalize to make tree amenable to register
// FP architectures
GenTree* Compiler::fgMorphForRegisterFP(GenTree* tree)
{
if (tree->OperIsArithmetic())
{
if (varTypeIsFloating(tree))
{
GenTree* op1 = tree->AsOp()->gtOp1;
GenTree* op2 = tree->gtGetOp2();

assert(varTypeIsFloating(op1->TypeGet()) && varTypeIsFloating(op2->TypeGet()));

if (op1->TypeGet() != tree->TypeGet())
{
tree->AsOp()->gtOp1 = gtNewCastNode(tree->TypeGet(), op1, false, tree->TypeGet());
}
if (op2->TypeGet() != tree->TypeGet())
{
tree->AsOp()->gtOp2 = gtNewCastNode(tree->TypeGet(), op2, false, tree->TypeGet());
}
}
}
else if (tree->OperIsCompare())
{
GenTree* op1 = tree->AsOp()->gtOp1;

if (varTypeIsFloating(op1))
{
GenTree* op2 = tree->gtGetOp2();
assert(varTypeIsFloating(op2));

if (op1->TypeGet() != op2->TypeGet())
{
// both had better be floating, just one bigger than other
if (op1->TypeGet() == TYP_FLOAT)
{
assert(op2->TypeGet() == TYP_DOUBLE);
tree->AsOp()->gtOp1 = gtNewCastNode(TYP_DOUBLE, op1, false, TYP_DOUBLE);
}
else if (op2->TypeGet() == TYP_FLOAT)
{
assert(op1->TypeGet() == TYP_DOUBLE);
tree->AsOp()->gtOp2 = gtNewCastNode(TYP_DOUBLE, op2, false, TYP_DOUBLE);
}
}
}
}

return tree;
}

#ifdef FEATURE_SIMD

//--------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -9601,11 +9549,6 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
AssertionIndex thenAssertionCount = DUMMY_INIT(0);
AssertionDsc* thenAssertionTab = DUMMY_INIT(NULL);

if (fgGlobalMorph)
{
tree = fgMorphForRegisterFP(tree);
}

genTreeOps oper = tree->OperGet();
var_types typ = tree->TypeGet();
GenTree* op1 = tree->AsOp()->gtOp1;
Expand Down

0 comments on commit 3429533

Please sign in to comment.