Skip to content

Commit 006f011

Browse files
committed
Simplify extractbits(concatenation(...))
1 parent 2163851 commit 006f011

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/util/simplify_expr_int.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected]
2020
#include "ieee_float.h"
2121
#include "invariant.h"
2222
#include "namespace.h"
23+
#include "pointer_offset_size.h"
2324
#include "rational.h"
2425
#include "rational_tools.h"
2526
#include "std_expr.h"
@@ -1143,6 +1144,30 @@ bool simplify_exprt::simplify_extractbits(extractbits_exprt &expr)
11431144

11441145
return false;
11451146
}
1147+
else if(expr.src().id() == ID_concatenation)
1148+
{
1149+
mp_integer offset = width;
1150+
1151+
forall_operands(it, expr.src())
1152+
{
1153+
mp_integer op_width = pointer_offset_bits(it->type(), ns);
1154+
1155+
if(op_width <= 0)
1156+
return true;
1157+
1158+
if(start + 1 == offset && end + op_width == offset)
1159+
{
1160+
exprt tmp = *it;
1161+
if(tmp.type() != expr.type())
1162+
tmp.make_typecast(expr.type());
1163+
expr.swap(tmp);
1164+
1165+
return false;
1166+
}
1167+
1168+
offset -= op_width;
1169+
}
1170+
}
11461171

11471172
return true;
11481173
}

0 commit comments

Comments
 (0)