| 1860 | } |
| 1861 | |
| 1862 | expr expr::concat(const expr &rhs) const { |
| 1863 | expr a, b, c, d; |
| 1864 | unsigned h, l, h2, l2; |
| 1865 | if (isExtract(a, h, l)) { |
| 1866 | if (rhs.isExtract(b, h2, l2) && l == h2+1) { |
| 1867 | if (a.eq(b)) |
| 1868 | return a.extract(h, l2); |
| 1869 | |
| 1870 | // (concat (extract (concat const X)) (extract X)) |
| 1871 | expr aa, ab; |
| 1872 | if (l2 == 0 && a.isConcat(aa, ab) && ab.eq(b) && |
| 1873 | (h - aa.bits()) == b.bits()) |
| 1874 | return aa.concat(b); |
| 1875 | } |
| 1876 | |
| 1877 | // extract_l concat (concat extract_r foo) |
| 1878 | if (rhs.isConcat(b, c) && b.isExtract(d, h2, l2) && l == h2+1 && a.eq(d)) |
| 1879 | return a.extract(h, l2).concat(c); |
| 1880 | } |
| 1881 | |
| 1882 | // (concat (concat x extract) extract) |
| 1883 | if (isConcat(a, b) && b.isExtract(c, h, l) && rhs.isExtract(d, h2, l2) && |
| 1884 | l == h2+1 && c.eq(d)) |
| 1885 | return a.concat(c.extract(h, l2)); |
| 1886 | |
| 1887 | // (concat const (concat const2 x)) |
| 1888 | if (isConst() && rhs.isConcat(a, b) && a.isConst()) |
| 1889 | return concat(a).concat(b); |
| 1890 | |
| 1891 | return binop_fold(rhs, Z3_mk_concat); |
| 1892 | } |
| 1893 | |
| 1894 | expr expr::concat_zeros(unsigned bits) const { |
| 1895 | return bits ? concat(mkUInt(0, bits)) : *this; |
no test coverage detected