Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Fix ValueNumStore::IsVNArrLenUnsignedBound checks
Browse files Browse the repository at this point in the history
VNFuncApp::m_func should be checked first to be sure that m_args[0] and m_args[1] contain valid VNs. It's not clear if m_func can ever be something other than a binary func in the case of a relop VN but the code doesn't look right as it is.
  • Loading branch information
mikedn committed Mar 16, 2017
1 parent f1087c7 commit 54b1709
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3182,21 +3182,21 @@ bool ValueNumStore::IsVNArrLenUnsignedBound(ValueNum vn, ArrLenUnsignedBoundInfo

if (GetVNFunc(vn, &funcApp))
{
if (IsVNArrLen(funcApp.m_args[1]))
if ((funcApp.m_func == VNF_LT_UN) || (funcApp.m_func == VNF_GE_UN))
{
// We only care about "(uint)i < (uint)a.len" and its negation "(uint)i >= (uint)a.len"
if ((funcApp.m_func == VNF_LT_UN) || (funcApp.m_func == VNF_GE_UN))
if (IsVNArrLen(funcApp.m_args[1]))
{
info->vnIdx = funcApp.m_args[0];
info->cmpOper = funcApp.m_func;
info->vnLen = funcApp.m_args[1];
return true;
}
}
else if (IsVNArrLen(funcApp.m_args[0]))
else if ((funcApp.m_func == VNF_GT_UN) || (funcApp.m_func == VNF_LE_UN))
{
// We only care about "(uint)a.len > (uint)i" and its negation "(uint)a.len <= (uint)i"
if ((funcApp.m_func == VNF_GT_UN) || (funcApp.m_func == VNF_LE_UN))
if (IsVNArrLen(funcApp.m_args[0]))
{
info->vnIdx = funcApp.m_args[1];
// Let's keep a consistent operand order - it's always i < a.len, never a.len > i
Expand Down

0 comments on commit 54b1709

Please sign in to comment.