Skip to content

Commit cac78f8

Browse files
committed
Check whether array index variable is an induction variable
In examining an array index for Idiom Recognition, analyzeOneArrayIndex checks whether the variable operand in a 'var + const' or 'const + var' expression is an induction variable. On the other hand, if the expression is a simple variable, the analysis assumes the variable reference is acceptable. However, it can happen that the variable used as the array index is not an induction variable which can result in an incorrect transformation. Fixed this by adding a check that an arrayindex that is a variable is also an induction variable. Fixes #15474 Signed-off-by: Henry Zongaro <zongaro@ca.ibm.com>
1 parent d0ee05f commit cac78f8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

runtime/compiler/optimizer/IdiomRecognition.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -7162,7 +7162,15 @@ TR_CISCTransformer::analyzeOneArrayIndex(TR_CISCNode *arrayindex, TR::SymbolRefe
71627162
}
71637163
if (!ret) return false;
71647164
}
7165-
else if (t->getOpcode() != TR_variable)
7165+
else if (t->getOpcode() == TR_variable)
7166+
{
7167+
TR::SymbolReference *symref = t->getHeadOfTrNodeInfo()->_node->getSymbolReference();
7168+
if (symref != inductionVariableSymRef)
7169+
{
7170+
return false;
7171+
}
7172+
}
7173+
else
71667174
{
71677175
return false;
71687176
}

0 commit comments

Comments
 (0)