Skip to content

Commit 6bbd218

Browse files
author
Meghana Gupta
committed
[MERGE #5177 @meg-gupta] Initialize local value table in path dependent branch folding for IntConstOpnds
Merge pull request #5177 from meg-gupta:unitbug We were not adding value of IntConstOpnd in the local value table, nor were we initializing it to null. This caused to incorrectly read value from the global value table, which might be inaccurate.
2 parents 012c0e8 + 21f2d1a commit 6bbd218

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/Backend/FlowGraph.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4646,7 +4646,17 @@ BasicBlock::CheckLegalityAndFoldPathDepBranches(GlobOpt* globOpt)
46464646
StackSym* src1Sym = instr->GetSrc1()->GetStackSym();
46474647
FindValueInLocalThenGlobalValueTableAndUpdate(globOpt, localSymToValueMap, instr, instr->GetDst()->GetSym(), src1Sym);
46484648
}
4649-
else if (!instr->GetSrc1()->IsIntConstOpnd())
4649+
else if (instr->GetSrc1()->IsIntConstOpnd())
4650+
{
4651+
Value **localValue = localSymToValueMap->FindOrInsertNew(instr->GetDst()->GetSym());
4652+
*localValue = globOpt->GetIntConstantValue(instr->GetSrc1()->AsIntConstOpnd()->AsInt32(), instr);
4653+
}
4654+
else if (instr->GetSrc1()->IsInt64ConstOpnd())
4655+
{
4656+
Value **localValue = localSymToValueMap->FindOrInsertNew(instr->GetDst()->GetSym());
4657+
*localValue = globOpt->GetIntConstantValue(instr->GetSrc1()->AsInt64ConstOpnd()->GetValue(), instr);
4658+
}
4659+
else
46504660
{
46514661
ValueType src1Value = instr->GetSrc1()->GetValueType();
46524662
Value **localValue = localSymToValueMap->FindOrInsertNew(instr->GetDst()->GetSym());

lib/Backend/GlobOpt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6515,7 +6515,7 @@ GlobOpt::CanProveConditionalBranch(IR::Instr *instr, Value *src1Val, Value *src2
65156515
//Assert(!src2Var || !Js::JavascriptOperators::IsObject(src2Var));
65166516

65176517
int64 left64, right64;
6518-
int left, right;
6518+
int32 left, right;
65196519
int32 constVal;
65206520

65216521
switch (instr->m_opcode)

0 commit comments

Comments
 (0)