@@ -1737,6 +1737,9 @@ br_status bv_rewriter::mk_bv_or(unsigned num, expr * const * args, expr_ref & re
1737
1737
default :
1738
1738
if (m_bv_sort_ac)
1739
1739
std::sort (new_args.begin (), new_args.end (), ast_to_lt ());
1740
+ if (distribute_concat (OP_BOR, new_args.size (), new_args.c_ptr (), result)) {
1741
+ return BR_REWRITE3;
1742
+ }
1740
1743
result = m_util.mk_bv_or (new_args.size (), new_args.c_ptr ());
1741
1744
return BR_DONE;
1742
1745
}
@@ -1863,8 +1866,12 @@ br_status bv_rewriter::mk_bv_xor(unsigned num, expr * const * args, expr_ref & r
1863
1866
}
1864
1867
1865
1868
if (!merged && !flattened && (num_coeffs == 0 || (num_coeffs == 1 && !v1.is_zero () && v1 != (rational::power_of_two (sz) - numeral (1 )))) &&
1866
- (!m_bv_sort_ac || is_sorted (num, args)))
1869
+ (!m_bv_sort_ac || is_sorted (num, args))) {
1870
+ if (distribute_concat (OP_BXOR, num, args, result)) {
1871
+ return BR_REWRITE3;
1872
+ }
1867
1873
return BR_FAILED;
1874
+ }
1868
1875
1869
1876
ptr_buffer<expr> new_args;
1870
1877
expr_ref c (m ()); // may not be used
@@ -1906,11 +1913,35 @@ br_status bv_rewriter::mk_bv_xor(unsigned num, expr * const * args, expr_ref & r
1906
1913
default :
1907
1914
if (m_bv_sort_ac)
1908
1915
std::sort (new_args.begin (), new_args.end (), ast_to_lt ());
1916
+ if (distribute_concat (OP_BXOR, new_args.size (), new_args.c_ptr (), result)) {
1917
+ return BR_REWRITE3;
1918
+ }
1909
1919
result = m_util.mk_bv_xor (new_args.size (), new_args.c_ptr ());
1910
1920
return BR_DONE;
1911
1921
}
1912
1922
}
1913
1923
1924
+ bool bv_rewriter::distribute_concat (decl_kind k, unsigned n, expr* const * args, expr_ref& result) {
1925
+ for (unsigned i = 0 ; i < n; ++i) {
1926
+ expr* arg = args[i];
1927
+ if (m_util.is_concat (arg)) {
1928
+ expr* e = to_app (arg)->get_arg (0 );
1929
+ unsigned sz1 = get_bv_size (e);
1930
+ unsigned sz2 = get_bv_size (arg);
1931
+ ptr_buffer<expr> args1, args2;
1932
+ for (unsigned j = 0 ; j < n; ++j) {
1933
+ args1.push_back (m_mk_extract (sz2-1 , sz1, args[j]));
1934
+ args2.push_back (m_mk_extract (sz1-1 ,0 , args[j]));
1935
+ }
1936
+ expr* arg1 = m ().mk_app (get_fid (), k, args1.size (), args1.c_ptr ());
1937
+ expr* arg2 = m ().mk_app (get_fid (), k, args2.size (), args2.c_ptr ());
1938
+ result = m_util.mk_concat (arg1, arg2);
1939
+ return true ;
1940
+ }
1941
+ }
1942
+ return false ;
1943
+ }
1944
+
1914
1945
br_status bv_rewriter::mk_bv_not (expr * arg, expr_ref & result) {
1915
1946
if (m_util.is_bv_not (arg)) {
1916
1947
result = to_app (arg)->get_arg (0 );
@@ -1925,17 +1956,14 @@ br_status bv_rewriter::mk_bv_not(expr * arg, expr_ref & result) {
1925
1956
return BR_DONE;
1926
1957
}
1927
1958
1928
- #if 1
1929
1959
if (m_util.is_concat (arg)) {
1930
1960
ptr_buffer<expr> new_args;
1931
- unsigned num = to_app (arg)->get_num_args ();
1932
- for (unsigned i = 0 ; i < num; i++) {
1933
- new_args.push_back (m_util.mk_bv_not (to_app (arg)->get_arg (i)));
1961
+ for (expr* a : *to_app (arg)) {
1962
+ new_args.push_back (m_util.mk_bv_not (a));
1934
1963
}
1935
1964
result = m_util.mk_concat (new_args.size (), new_args.c_ptr ());
1936
1965
return BR_REWRITE2;
1937
1966
}
1938
- #endif
1939
1967
1940
1968
if (m_bvnot2arith) {
1941
1969
// (bvnot x) --> (bvsub -1 x)
0 commit comments