Skip to content

Commit 9c59fe8

Browse files
committed
Fix logic, update comment
1 parent 15be0fe commit 9c59fe8

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/coreclr/jit/codegenlinear.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,21 +1214,21 @@ void CodeGen::genUnspillRegIfNeeded(GenTree* tree)
12141214
GenTreeLclVar* lcl = unspillTree->AsLclVar();
12151215
LclVarDsc* varDsc = compiler->lvaGetDesc(lcl);
12161216

1217-
// Pick type to reload register from stack with. Note that for
1218-
// normalize-on-load variables the type of 'lcl' does not have any
1219-
// relation to the type of 'varDsc':
1220-
// * It is wider under normal circumstances, where morph has added a cast on top
1221-
// * It is the same in many circumstances, e.g. when morph tries to
1222-
// guess via a subrange assertion that the upper bits are going to
1223-
// be zero.
1224-
// * It is narrower in some cases, e.g. when lowering optimizes to
1225-
// use a byte `cmp`
1217+
// Pick type to reload register from stack with. Note that in
1218+
// general, the type of 'lcl' does not have any relation to the
1219+
// type of 'varDsc':
12261220
//
1227-
// For unspilling purposes we should always make sure we get a
1228-
// normalized value in the register, so use the type from the
1229-
// varDsc.
1221+
// * For NOL locals it is wider under normal circumstances, where
1222+
// morph has added a cast on top
1223+
// * For all locals it can be narrower narrower in some cases, e.g.
1224+
// when lowering optimizes to use a smaller typed `cmp` (e.g.
1225+
// 32-bit cmp for 64-bit local, or 8-bit cmp for 16-bit local).
1226+
//
1227+
// Thus, we should always pick the type from varDsc. For NOL locals
1228+
// we further want to make sure we always leave a normalized value
1229+
// in the register.
12301230

1231-
var_types unspillType = varDsc->lvNormalizeOnLoad() ? varDsc->TypeGet() : varDsc->GetRegisterType(lcl);
1231+
var_types unspillType = varDsc->lvNormalizeOnLoad() ? varDsc->TypeGet() : varDsc->GetStackSlotHomeType();
12321232
assert(unspillType != TYP_UNDEF);
12331233

12341234
#if defined(TARGET_LOONGARCH64)

0 commit comments

Comments
 (0)