Skip to content

Commit 6e02c69

Browse files
Apply L2 renaming in field_sensitivityt::apply
L2 renaming is necessary for constant propagation, which may be necessary to detect arrays of constant size. This is consistent with what happens with get_fields, since there L2 renaming is applied before the call to the function.
1 parent a804175 commit 6e02c69

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/goto-symex/field_sensitivity.cpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,33 @@ exprt field_sensitivityt::apply(
8585
// encoding the index access into an array as an individual symbol rather
8686
// than only the full array
8787
index_exprt &index = to_index_expr(expr);
88-
simplify(index.index(), ns);
8988

9089
if(
9190
index.array().id() == ID_symbol &&
9291
index.array().get_bool(ID_C_SSA_symbol) &&
93-
index.array().type().id() == ID_array &&
94-
to_array_type(index.array().type()).size().id() == ID_constant &&
95-
index.index().id() == ID_constant)
92+
index.array().type().id() == ID_array)
9693
{
97-
// place the entire index expression, not just the array operand, in an
98-
// SSA expression
9994
ssa_exprt tmp = to_ssa_expr(index.array());
95+
auto l2_index = state.rename(index.index(), ns);
96+
l2_index.simplify(ns);
97+
auto l2_array = state.rename(index.array(), ns);
10098
bool was_l2 = !tmp.get_level_2().empty();
101-
102-
tmp.remove_level_2();
103-
index.array() = tmp.get_original_expr();
104-
tmp.set_expression(index);
105-
if(was_l2)
106-
return state.rename(std::move(tmp), ns).get();
107-
else
108-
return std::move(tmp);
99+
if(
100+
to_array_type(l2_array.get().type()).size().id() == ID_constant &&
101+
l2_index.get().id() == ID_constant)
102+
{
103+
// place the entire index expression, not just the array operand, in an
104+
// SSA expression
105+
ssa_exprt ssa_array = to_ssa_expr(l2_array.get());
106+
ssa_array.remove_level_2();
107+
index.array() = ssa_array.get_original_expr();
108+
index.index() = l2_index.get();
109+
tmp.set_expression(index);
110+
if(was_l2)
111+
return state.rename(std::move(tmp), ns).get();
112+
else
113+
return std::move(tmp);
114+
}
109115
}
110116
}
111117
#endif // ENABLE_ARRAY_FIELD_SENSITIVITY

0 commit comments

Comments
 (0)