https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105148
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
- MEM <int[1][0:D.2027]> [(int[1][0:D.1996] *)y.1_8][5]{lb: 0 sz: _6 * 4}[i_2]
= 0;
+ MEM <int[1][0:D.2027]> [(int[1][0:D.1996] *)y.1_8][5]{lb: 0 sz: <<< error
>>>}[i_2] = 0;
find_interesting_uses_op fails to consider _6 * 4, in fact idx_record_use
does
if (TREE_CODE (base) == ARRAY_REF || TREE_CODE (base) == ARRAY_RANGE_REF)
{
find_interesting_uses_op (data, array_ref_element_size (base));
find_interesting_uses_op (data, array_ref_low_bound (base));
}
but it should probably pass down the raw TREE_OPERANDs, not the scaled
array_ref_element_size ().
I have a patch:
diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc
index b0305c494cd..81b536f9304 100644
--- a/gcc/tree-ssa-loop-ivopts.cc
+++ b/gcc/tree-ssa-loop-ivopts.cc
@@ -2124,8 +2124,10 @@ idx_record_use (tree base, tree *idx,
find_interesting_uses_op (data, *idx);
if (TREE_CODE (base) == ARRAY_REF || TREE_CODE (base) == ARRAY_RANGE_REF)
{
- find_interesting_uses_op (data, array_ref_element_size (base));
- find_interesting_uses_op (data, array_ref_low_bound (base));
+ if (TREE_OPERAND (base, 2))
+ find_interesting_uses_op (data, TREE_OPERAND (base, 2));
+ if (TREE_OPERAND (base, 3))
+ find_interesting_uses_op (data, TREE_OPERAND (base, 3));
}
return true;
}