@@ -976,13 +976,23 @@ bvt bv_utilst::multiplier(
976
976
const bvt &op1,
977
977
representationt rep)
978
978
{
979
+ auto cache_entry =
980
+ circuit_cache[{ID_mult, rep}].insert ({{op0, op1}, {bvt{}}});
981
+ if (!cache_entry.second )
982
+ return cache_entry.first ->second [0 ];
983
+
979
984
switch (rep)
980
985
{
981
- case representationt::SIGNED: return signed_multiplier (op0, op1);
982
- case representationt::UNSIGNED: return unsigned_multiplier (op0, op1);
986
+ case representationt::SIGNED:
987
+ cache_entry.first ->second [0 ] = signed_multiplier (op0, op1);
988
+ case representationt::UNSIGNED:
989
+ cache_entry.first ->second [0 ] = unsigned_multiplier (op0, op1);
983
990
}
984
991
985
- UNREACHABLE;
992
+ // multiplication is commutative
993
+ circuit_cache[{ID_mult, rep}][{op1, op0}] = {cache_entry.first ->second };
994
+
995
+ return cache_entry.first ->second [0 ];
986
996
}
987
997
988
998
bvt bv_utilst::multiplier_no_overflow (
@@ -1045,13 +1055,25 @@ void bv_utilst::divider(
1045
1055
{
1046
1056
PRECONDITION (prop.has_set_to ());
1047
1057
1058
+ auto cache_entry =
1059
+ circuit_cache[{ID_div, rep}].insert ({{op0, op1}, {bvt{}, bvt{}}});
1060
+ if (!cache_entry.second )
1061
+ {
1062
+ result = cache_entry.first ->second [0 ];
1063
+ remainer = cache_entry.first ->second [1 ];
1064
+ return ;
1065
+ }
1066
+
1048
1067
switch (rep)
1049
1068
{
1050
1069
case representationt::SIGNED:
1051
1070
signed_divider (op0, op1, result, remainer); break ;
1052
1071
case representationt::UNSIGNED:
1053
1072
unsigned_divider (op0, op1, result, remainer); break ;
1054
1073
}
1074
+
1075
+ cache_entry.first ->second [0 ] = result;
1076
+ cache_entry.first ->second [1 ] = remainer;
1055
1077
}
1056
1078
1057
1079
void bv_utilst::unsigned_divider (
0 commit comments