Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 6f8f215

Browse files
committed
Allow uncontained GT_LONG nodes
When the result of a TYP_LONG operation is not used the GT_LONG node inserted during decomposition remains in the tree and unlike other GT_LONG nodes is not contained and needs special handling. This usually happens with arithmetic operations that require overflow checks, the result of the operation may be ignored but the operation itself cannot be eliminated because it has a side-effect.
1 parent 07fd84e commit 6f8f215

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/jit/codegenxarch.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,6 +2728,13 @@ CodeGen::genCodeForTreeNode(GenTreePtr treeNode)
27282728
genProduceReg(treeNode);
27292729
break;
27302730

2731+
#if !defined(_TARGET_64BIT_)
2732+
case GT_LONG:
2733+
assert(!treeNode->isContained());
2734+
genConsumeRegs(treeNode);
2735+
break;
2736+
#endif
2737+
27312738
default:
27322739
{
27332740
#ifdef DEBUG

src/jit/gentree.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13235,6 +13235,14 @@ bool GenTree::isContained() const
1323513235
#endif
1323613236
return false;
1323713237

13238+
#if !defined(LEGACY_BACKEND) && !defined(_TARGET_64BIT_)
13239+
case GT_LONG:
13240+
// GT_LONG nodes are normally contained. The only exception is when the result
13241+
// of a TYP_LONG operation is not used and this can only happen if the GT_LONG
13242+
// is the last node in the statement (in linear order).
13243+
return gtNext != nullptr;
13244+
#endif
13245+
1323813246
case GT_CALL:
1323913247
// Note: if you hit this assert you are probably calling isContained()
1324013248
// before the LSRA phase has allocated physical register to the tree nodes

src/jit/lowerxarch.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,16 @@ void Lowering::TreeNodeInfoInit(GenTree* stmt)
247247
#if !defined(_TARGET_64BIT_)
248248

249249
case GT_LONG:
250-
// Passthrough
251-
info->srcCount = 0;
250+
if (tree->gtNext == nullptr)
251+
{
252+
// An uncontained GT_LONG node needs to consume its source operands
253+
info->srcCount = 2;
254+
}
255+
else
256+
{
257+
// Passthrough
258+
info->srcCount = 0;
259+
}
252260
info->dstCount = 0;
253261
break;
254262

0 commit comments

Comments
 (0)