Skip to content

Commit

Permalink
Improve TP a little
Browse files Browse the repository at this point in the history
  • Loading branch information
SingleAccretion committed Oct 27, 2023
1 parent a4169f5 commit f839217
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
8 changes: 3 additions & 5 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14429,12 +14429,12 @@ GenTree* Compiler::gtFoldBoxNullable(GenTree* tree)
GenTree* op;
GenTree* cons;

if (op1->IsCnsIntOrI())
if (op1->IsIntegralConst())
{
op = op2;
cons = op1;
}
else if (op2->IsCnsIntOrI())
else if (op2->IsIntegralConst())
{
op = op1;
cons = op2;
Expand All @@ -14444,9 +14444,7 @@ GenTree* Compiler::gtFoldBoxNullable(GenTree* tree)
return tree;
}

ssize_t const val = cons->AsIntCon()->IconValue();

if (val != 0)
if (cons->AsIntCon()->IntegralValue() != 0)
{
return tree;
}
Expand Down
10 changes: 6 additions & 4 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ struct GenTree

bool IsConstInitVal() const
{
return IsCnsIntOrI() || (OperIsInitVal() && gtGetOp1()->IsCnsIntOrI());
return IsIntegralConst() || (OperIsInitVal() && gtGetOp1()->IsIntegralConst());
}

bool OperIsBlkOp();
Expand Down Expand Up @@ -2208,15 +2208,17 @@ struct GenTree

bool IsIconHandle() const
{
return (IsCnsIntOrI()) && ((gtFlags & GTF_ICON_HDL_MASK) != 0);
bool isIconHandle = IsIntegralConst() && ((gtFlags & GTF_ICON_HDL_MASK) != 0);
assert(!isIconHandle || varTypeIsI(this));
return isIconHandle;
}

bool IsIconHandle(GenTreeFlags handleType) const
{
// check that handleType is one of the valid GTF_ICON_* values
assert((handleType & GTF_ICON_HDL_MASK) != 0);
assert((handleType & ~GTF_ICON_HDL_MASK) == 0);
return IsCnsIntOrI() && ((gtFlags & GTF_ICON_HDL_MASK) == handleType);
return IsIntegralConst() && ((gtFlags & GTF_ICON_HDL_MASK) == handleType);
}

template <typename... T>
Expand All @@ -2229,7 +2231,7 @@ struct GenTree
// For non-icon handle trees, returns GTF_EMPTY.
GenTreeFlags GetIconHandleFlag() const
{
return (IsCnsIntOrI()) ? (gtFlags & GTF_ICON_HDL_MASK) : GTF_EMPTY;
return IsIntegralConst() ? (gtFlags & GTF_ICON_HDL_MASK) : GTF_EMPTY;
}

// Mark this node as no longer being a handle; clear its GTF_ICON_*_HDL bits.
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6908,7 +6908,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
assertImp(op1->TypeIs(TYP_REF));

// Check for null pointer - in the inliner case we simply abort.
if (compIsForInlining() && op1->IsCnsIntOrI())
if (compIsForInlining() && op1->IsIntegralConst())
{
compInlineResult->NoteFatal(InlineObservation::CALLEE_HAS_NULL_FOR_LDELEM);
return;
Expand Down
16 changes: 8 additions & 8 deletions src/coreclr/jit/lowerarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bool Lowering::IsContainableImmed(GenTree* parentNode, GenTree* childNode) const
#endif

// Make sure we have an actual immediate
if (!childNode->IsCnsIntOrI())
if (!childNode->IsIntegralConst())
return false;
if (childNode->AsIntCon()->ImmedValNeedsReloc(comp))
return false;
Expand Down Expand Up @@ -250,7 +250,7 @@ bool Lowering::IsContainableUnaryOrBinaryOp(GenTree* parentNode, GenTree* childN

GenTree* shiftAmountNode = childNode->gtGetOp2();

if (!shiftAmountNode->IsCnsIntOrI())
if (!shiftAmountNode->IsIntegralConst())
{
// Cannot contain if the childs op2 is not a constant
return false;
Expand Down Expand Up @@ -397,7 +397,7 @@ void Lowering::LowerStoreLoc(GenTreeLclVarCommon* storeLoc)
// On ARM, small stores can cost a bit more in terms of code size so we try to widen them. This is legal
// as most small locals have 4-byte-wide stack homes, the common exception being (dependent) struct fields.
//
if (storeLoc->OperIs(GT_STORE_LCL_VAR) && varTypeIsSmall(storeLoc) && storeLoc->Data()->IsCnsIntOrI())
if (storeLoc->OperIs(GT_STORE_LCL_VAR) && varTypeIsSmall(storeLoc) && storeLoc->Data()->IsIntegralConst())
{
LclVarDsc* varDsc = comp->lvaGetDesc(storeLoc);
if (!varDsc->lvIsStructField && (varDsc->GetStackSlotHomeType() == TYP_INT))
Expand Down Expand Up @@ -571,7 +571,7 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode)
}

if (!blkNode->OperIs(GT_STORE_DYN_BLK) && (size <= comp->getUnrollThreshold(Compiler::UnrollKind::Memset)) &&
src->IsCnsIntOrI())
src->IsIntegralConst())
{
blkNode->gtBlkOpKind = GenTreeBlk::BlkOpKindUnroll;

Expand Down Expand Up @@ -688,7 +688,7 @@ void Lowering::ContainBlockStoreAddress(GenTreeBlk* blkNode, unsigned size, GenT
return;
}

if (!addr->OperIs(GT_ADD) || addr->gtOverflow() || !addr->AsOp()->gtGetOp2()->IsCnsIntOrI())
if (!addr->OperIs(GT_ADD) || addr->gtOverflow() || !addr->AsOp()->gtGetOp2()->IsIntegralConst())
{
return;
}
Expand Down Expand Up @@ -811,7 +811,7 @@ void Lowering::LowerRotate(GenTree* tree)
unsigned rotatedValueBitSize = genTypeSize(rotatedValue->gtType) * 8;
GenTree* rotateLeftIndexNode = tree->AsOp()->gtOp2;

if (rotateLeftIndexNode->IsCnsIntOrI())
if (rotateLeftIndexNode->IsIntegralConst())
{
ssize_t rotateLeftIndex = rotateLeftIndexNode->AsIntCon()->IconValue();
ssize_t rotateRightIndex = rotatedValueBitSize - rotateLeftIndex;
Expand Down Expand Up @@ -1223,7 +1223,7 @@ bool Lowering::IsValidConstForMovImm(GenTreeHWIntrinsic* node)
op1 = castOp;
}

if (op1->IsCnsIntOrI())
if (op1->IsIntegralConst())
{
const ssize_t dataValue = op1->AsIntCon()->IconValue();

Expand Down Expand Up @@ -2149,7 +2149,7 @@ void Lowering::ContainCheckShiftRotate(GenTreeOp* node)
}
#endif // TARGET_ARM

if (shiftBy->IsCnsIntOrI())
if (shiftBy->IsIntegralConst())
{
MakeSrcContained(node, shiftBy);
}
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/lsrabuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4348,14 +4348,14 @@ int LinearScan::BuildCmpOperands(GenTree* tree)
// Example2: GT_EQ(int, op1 of type ubyte, op2 is GT_CNS_INT) - in this case codegen uses
// ubyte as the result of the comparison and if the result needs to be materialized into a reg
// simply zero extend it to TYP_INT size.
else if (varTypeIsByte(op1) && op2->IsCnsIntOrI())
else if (varTypeIsByte(op1) && op2->IsIntegralConst())
{
needByteRegs = true;
}
// Example3: GT_EQ(int, op1 is GT_CNS_INT, op2 of type ubyte) - in this case codegen uses
// ubyte as the result of the comparison and if the result needs to be materialized into a reg
// simply zero extend it to TYP_INT size.
else if (op1->IsCnsIntOrI() && varTypeIsByte(op2))
else if (op1->IsIntegralConst() && varTypeIsByte(op2))
{
needByteRegs = true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11130,7 +11130,7 @@ GenTree* Compiler::fgOptimizeAddition(GenTreeOp* add)
if (op2->IsIntegralConst(0) && (genActualType(add) == genActualType(op1)))
{
// Keep the offset nodes with annotations for value numbering purposes.
if (!op2->IsCnsIntOrI() || (op2->AsIntCon()->gtFieldSeq == nullptr))
if (op2->AsIntCon()->gtFieldSeq == nullptr)
{
DEBUG_DESTROY_NODE(op2);
DEBUG_DESTROY_NODE(add);
Expand All @@ -11146,7 +11146,7 @@ GenTree* Compiler::fgOptimizeAddition(GenTreeOp* add)
{
// Reduce local addresses: "ADD(LCL_ADDR, OFFSET)" => "LCL_FLD_ADDR".
//
if (op1->OperIs(GT_LCL_ADDR) && op2->IsCnsIntOrI())
if (op1->OperIs(GT_LCL_ADDR) && op2->IsIntegralConst())
{
GenTreeLclVarCommon* lclAddrNode = op1->AsLclVarCommon();
GenTreeIntCon* offsetNode = op2->AsIntCon();
Expand Down

0 comments on commit f839217

Please sign in to comment.