@@ -2136,10 +2136,30 @@ static exprt lower_byte_update(
2136
2136
instantiate_byte_array (value_as_byte_array, 0 , (type_bits + 7 ) / 8 , ns);
2137
2137
}
2138
2138
2139
+ const std::size_t update_size = update_bytes.size ();
2140
+ const std::size_t width = std::max (type_bits, update_size * 8 );
2141
+
2142
+ const bool is_little_endian = src.id () == ID_byte_update_little_endian;
2143
+
2144
+ exprt val_before =
2145
+ typecast_exprt::conditional_cast (src.op (), bv_typet{type_bits});
2146
+ if (width > type_bits)
2147
+ {
2148
+ val_before =
2149
+ concatenation_exprt{from_integer (0 , bv_typet{width - type_bits}),
2150
+ val_before,
2151
+ bv_typet{width}};
2152
+
2153
+ if (!is_little_endian)
2154
+ to_concatenation_expr (val_before)
2155
+ .op0 ()
2156
+ .swap (to_concatenation_expr (val_before).op1 ());
2157
+ }
2158
+
2139
2159
if (non_const_update_bound.has_value ())
2140
2160
{
2141
2161
const exprt src_as_bytes = unpack_rec (
2142
- src. op () ,
2162
+ val_before ,
2143
2163
src.id () == ID_byte_update_little_endian,
2144
2164
mp_integer{0 },
2145
2165
mp_integer{update_bytes.size ()},
@@ -2158,11 +2178,6 @@ static exprt lower_byte_update(
2158
2178
}
2159
2179
}
2160
2180
2161
- const std::size_t update_size = update_bytes.size ();
2162
- const std::size_t width = std::max (type_bits, update_size * 8 );
2163
-
2164
- const bool is_little_endian = src.id () == ID_byte_update_little_endian;
2165
-
2166
2181
// build mask
2167
2182
exprt mask;
2168
2183
if (is_little_endian)
@@ -2186,20 +2201,6 @@ static exprt lower_byte_update(
2186
2201
mask_shifted.true_case ().swap (mask_shifted.false_case ());
2187
2202
2188
2203
// original_bits &= ~mask
2189
- exprt val_before =
2190
- typecast_exprt::conditional_cast (src.op (), bv_typet{type_bits});
2191
- if (width > type_bits)
2192
- {
2193
- val_before =
2194
- concatenation_exprt{from_integer (0 , bv_typet{width - type_bits}),
2195
- val_before,
2196
- bv_typet{width}};
2197
-
2198
- if (!is_little_endian)
2199
- to_concatenation_expr (val_before)
2200
- .op0 ()
2201
- .swap (to_concatenation_expr (val_before).op1 ());
2202
- }
2203
2204
bitand_exprt bitand_expr{val_before, bitnot_exprt{mask_shifted}};
2204
2205
2205
2206
// concatenate and zero-extend the value
@@ -2242,6 +2243,14 @@ static exprt lower_byte_update(
2242
2243
src.type ()),
2243
2244
ns);
2244
2245
}
2246
+ else if (width > type_bits)
2247
+ {
2248
+ return simplify_expr (
2249
+ typecast_exprt::conditional_cast (
2250
+ extractbits_exprt{bitor_expr, type_bits - 1 , 0 , bv_typet{type_bits}},
2251
+ src.type ()),
2252
+ ns);
2253
+ }
2245
2254
2246
2255
return simplify_expr (
2247
2256
typecast_exprt::conditional_cast (bitor_expr, src.type ()), ns);
0 commit comments