Skip to content

Commit dfc835a

Browse files
author
Meghana Gupta
committed
Initialize local value table in path dependent branch folding for IntConstOpnds
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.
1 parent 649c895 commit dfc835a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/Backend/FlowGraph.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4646,7 +4646,18 @@ 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->NewValue(IntConstantValueInfo::New(globOpt->alloc, instr->GetSrc1()->AsIntConstOpnd()->AsInt32()));
4653+
}
4654+
else if (instr->GetSrc1()->IsInt64ConstOpnd())
4655+
{
4656+
Value **localValue = localSymToValueMap->FindOrInsertNew(instr->GetDst()->GetSym());
4657+
int64 intValue = instr->GetSrc1()->AsInt64ConstOpnd()->GetValue();
4658+
*localValue = globOpt->NewValue(Int64ConstantValueInfo::New(globOpt->alloc, intValue));
4659+
}
4660+
else
46504661
{
46514662
ValueType src1Value = instr->GetSrc1()->GetValueType();
46524663
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
@@ -6525,7 +6525,7 @@ GlobOpt::CanProveConditionalBranch(IR::Instr *instr, Value *src1Val, Value *src2
65256525
//Assert(!src2Var || !Js::JavascriptOperators::IsObject(src2Var));
65266526

65276527
int64 left64, right64;
6528-
int left, right;
6528+
int32 left, right;
65296529
int32 constVal;
65306530

65316531
switch (instr->m_opcode)

0 commit comments

Comments
 (0)