Skip to content

Commit 178f8db

Browse files
committed
Fixed mRegCost int/float cross-indexing
1 parent 1ccdf78 commit 178f8db

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

IDEHelper/Backend/BeMCContext.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -877,17 +877,18 @@ void BeMCColorizer::Node::AdjustRegCost(X64CPURegister reg, int adjust)
877877
BF_ASSERT((int)reg >= 0);
878878
BF_ASSERT((int)reg < X64Reg_COUNT);
879879

880-
#ifdef BE_REGCOST_SIZE
880+
#ifdef BE_REGCOST_SIZE
881881
int costIdx = sRegCostIdxMap[(int)reg];
882+
bool isFloat = (reg >= X64Reg_XMM0_f64) && (reg <= X64Reg_M128_XMM15);
883+
if (isFloat != mRegCostFloat)
884+
costIdx = -1;
882885
#else
883886
int costIdx = (int)reg;
884887
#endif
885888
if (costIdx == -1)
886889
return;
887890
int newCost = mRegCost[costIdx] + adjust;
888-
mRegCost[costIdx] = newCost;
889-
if (newCost < mLowestRegCost)
890-
mLowestRegCost = newCost;
891+
mRegCost[costIdx] = newCost;
891892
}
892893

893894
int BeMCColorizer::Node::GetRegCost(X64CPURegister reg)
@@ -897,6 +898,9 @@ int BeMCColorizer::Node::GetRegCost(X64CPURegister reg)
897898

898899
#ifdef BE_REGCOST_SIZE
899900
int costIdx = sRegCostIdxMap[(int)reg];
901+
bool isFloat = (reg >= X64Reg_XMM0_f64) && (reg <= X64Reg_M128_XMM15);
902+
if (isFloat != mRegCostFloat)
903+
costIdx = -1;
900904
#else
901905
int costIdx = (int)reg;
902906
#endif
@@ -1408,8 +1412,10 @@ void BeMCColorizer::AssignRegs(RegKind regKind)
14081412

14091413
if (canBeReg)
14101414
{
1415+
#ifdef BE_REGCOST_SIZE
14111416
if (clearCosts)
1412-
node->ClearRegCosts();
1417+
node->SetRegCostFloat();
1418+
#endif
14131419
node->mInGraph = true;
14141420
node->mGraphEdgeCount = 0;
14151421
vregGraph.push_back(vregIdx);

IDEHelper/Backend/BeMCContext.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,14 +1127,13 @@ class BeMCColorizer
11271127
int mGraphEdgeCount;
11281128
bool mInGraph;
11291129
bool mSpilled;
1130-
bool mWantsReg;
1130+
bool mWantsReg;
11311131
#ifdef BE_REGCOST_SIZE
1132-
int mRegCost[BE_REGCOST_SIZE];
1132+
bool mRegCostFloat;
1133+
int mRegCost[BE_REGCOST_SIZE];
11331134
#else
11341135
int mRegCost[X64Reg_COUNT];
1135-
#endif
1136-
1137-
int mLowestRegCost;
1136+
#endif
11381137
int mMemCost;
11391138
//int mActualVRegIdx;
11401139

@@ -1145,10 +1144,10 @@ class BeMCColorizer
11451144

11461145
void AdjustRegCost(X64CPURegister reg, int adjust);
11471146

1148-
void ClearRegCosts()
1149-
{
1150-
mLowestRegCost = 0;
1147+
void SetRegCostFloat()
1148+
{
11511149
memset(mRegCost, 0, sizeof(mRegCost));
1150+
mRegCostFloat = true;
11521151
}
11531152

11541153
int GetRegCost(X64CPURegister reg);
@@ -1158,9 +1157,9 @@ class BeMCColorizer
11581157
mWantsReg = false;
11591158
mInGraph = false;
11601159
mSpilled = false;
1161-
mGraphEdgeCount = 0;
1162-
mLowestRegCost = 0;
1160+
mGraphEdgeCount = 0;
11631161
mMemCost = 0;
1162+
mRegCostFloat = false;
11641163
memset(mRegCost, 0, sizeof(mRegCost));
11651164
//mActualVRegIdx = -1;
11661165
}

0 commit comments

Comments
 (0)