summaryrefslogtreecommitdiff
path: root/src/jit/gentree.h
diff options
context:
space:
mode:
authorCarol Eidt <carol.eidt@microsoft.com>2018-09-20 10:35:32 -0700
committerCarol Eidt <carol.eidt@microsoft.com>2018-09-20 10:35:32 -0700
commit4d65684d041045edd46c9523b6b51e6e17f560f4 (patch)
treedbc749518db9e58ebe226cdc9d3096322e1aa76c /src/jit/gentree.h
parent4e111c3495c480c221ee8ba577bf9837a2e98271 (diff)
downloadcoreclr-4d65684d041045edd46c9523b6b51e6e17f560f4.tar.gz
coreclr-4d65684d041045edd46c9523b6b51e6e17f560f4.tar.bz2
coreclr-4d65684d041045edd46c9523b6b51e6e17f560f4.zip
Handle partial multireg COPY
A multireg COPY will only have a valid register for indices that require copying. Thus, the `GetRegCount` method must return the highest index that has a valid register. Fix #20063
Diffstat (limited to 'src/jit/gentree.h')
-rw-r--r--src/jit/gentree.h19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/jit/gentree.h b/src/jit/gentree.h
index dbb5a75913..a0c86fbfbc 100644
--- a/src/jit/gentree.h
+++ b/src/jit/gentree.h
@@ -5535,22 +5535,21 @@ struct GenTreeCopyOrReload : public GenTreeUnOp
unsigned GetRegCount()
{
- if (gtRegNum == REG_NA)
- {
- return 0;
- }
#if FEATURE_MULTIREG_RET
- for (unsigned i = 0; i < MAX_RET_REG_COUNT - 1; ++i)
+ // We need to return the highest index for which we have a valid register.
+ // Note that the gtOtherRegs array is off by one (the 0th register is gtRegNum).
+ // If there's no valid register in gtOtherRegs, gtRegNum must be valid.
+ for (unsigned i = MAX_RET_REG_COUNT; i > 1; i--)
{
- if (gtOtherRegs[i] == REG_NA)
+ if (gtOtherRegs[i - 2] != REG_NA)
{
- return i + 1;
+ return i;
}
}
- return MAX_RET_REG_COUNT;
-#else
- return 1;
#endif
+ // We should never have a COPY or RELOAD with no valid registers.
+ assert(gtRegNum != REG_NA);
+ return 1;
}
GenTreeCopyOrReload(genTreeOps oper, var_types type, GenTree* op1) : GenTreeUnOp(oper, type, op1)