Skip to content

Commit f746c86

Browse files
committed
Simplify byte extract: use lowering when expression is a constant
When none of the earlier simplification rules apply, rewrite the expression to to apply simplification rules for arithmetic and logic expressions.
1 parent ef4e270 commit f746c86

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/util/simplify_expr.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,10 +1970,13 @@ simplify_exprt::simplify_byte_extract(const byte_extract_exprt &expr)
19701970
// try to refine it down to extracting from a member or an index in an array
19711971
auto subexpr =
19721972
get_subexpression_at_offset(expr.op(), *offset, expr.type(), ns);
1973-
if(!subexpr.has_value() || subexpr.value() == expr)
1974-
return unchanged(expr);
1973+
if(subexpr.has_value() && subexpr.value() != expr)
1974+
return changed(simplify_rec(subexpr.value())); // recursive call
1975+
1976+
if(is_constantt(ns)(expr))
1977+
return changed(simplify_rec(lower_byte_extract(expr, ns)));
19751978

1976-
return changed(simplify_rec(subexpr.value())); // recursive call
1979+
return unchanged(expr);
19771980
}
19781981

19791982
simplify_exprt::resultt<>

0 commit comments

Comments
 (0)