@@ -1571,17 +1571,19 @@ void CodeGen::genLclHeap(GenTree* tree)
1571
1571
if (compiler->compOpportunisticallyDependsOn (InstructionSet_Zbb))
1572
1572
{
1573
1573
emit->emitIns_R_R_R (INS_maxu, EA_PTRSIZE, tempReg, REG_SPBASE, regCnt);
1574
- emit->emitIns_R_R_R (INS_sub, EA_PTRSIZE, regCnt, tempReg, regCnt);
1574
+ emit->emitIns_R_R_R (INS_sub, EA_PTRSIZE, regCnt, tempReg, regCnt); // regCnt now holds ultimate SP
1575
1575
}
1576
1576
else
1577
1577
{
1578
- emit->emitIns_R_R_R (INS_sub, EA_PTRSIZE, regCnt, REG_SPBASE, regCnt); // cnt = sp - cnt; // ultimate SP
1579
- // If the subtraction above overflowed (i.e. sp < ultimateSP), set regCnt to lowest possible value (i.e. 0)
1580
1578
emit->emitIns_R_R_R (INS_sltu, EA_PTRSIZE, tempReg, REG_SPBASE, regCnt); // temp = overflow ? 1 : 0;
1581
- emit->emitIns_R_R_I (INS_addi, EA_PTRSIZE, tempReg, tempReg, -1 ); // temp = overflow ? 0 : full_mask;
1582
- emit->emitIns_R_R_R (INS_and, EA_PTRSIZE, regCnt, regCnt, tempReg); // cnt = overflow ? 0 : cnt;
1579
+
1580
+ // sub regCnt, SP, regCnt // regCnt now holds ultimate SP
1581
+ emit->emitIns_R_R_R (INS_sub, EA_PTRSIZE, regCnt, REG_SPBASE, regCnt);
1582
+
1583
+ // If overflow, set regCnt to lowest possible value
1584
+ emit->emitIns_R_R_I (INS_addi, EA_PTRSIZE, tempReg, tempReg, -1 ); // temp = overflow ? 0 : full_mask;
1585
+ emit->emitIns_R_R_R (INS_and, EA_PTRSIZE, regCnt, regCnt, tempReg); // cnt = overflow ? 0 : cnt;
1583
1586
}
1584
- // At this point 'regCnt' is set to the ultimate SP.
1585
1587
1586
1588
regNumber rPageSize = internalRegisters.GetSingle (tree);
1587
1589
noway_assert (rPageSize != tempReg);
0 commit comments