@@ -1855,11 +1855,12 @@ expr Memory::int2ptr(const expr &val) const {
18551855 return expr::mkIf (val == 0 , null, fn);
18561856}
18571857
1858- expr Memory::blockValRefined (const Memory &other, unsigned bid, bool local,
1858+ expr Memory::blockValRefined (const Memory &other, unsigned bid,
1859+ optional<unsigned > bid_other,
18591860 const expr &offset, set<expr> &undef) const {
1860- assert (!local) ;
1861- auto &mem1 = non_local_block_val[bid];
1862- auto &mem2 = other.non_local_block_val [bid].val ;
1861+ auto &mem1 = (bid_other ? local_block_val : non_local_block_val)[bid] ;
1862+ auto &mem2 = bid_other ? other. local_block_val [*bid_other]. val :
1863+ other.non_local_block_val [bid].val ;
18631864
18641865 if (mem1.val .eq (mem2))
18651866 return true ;
@@ -1890,7 +1891,23 @@ expr Memory::blockValRefined(const Memory &other, unsigned bid, bool local,
18901891 return val.refined (val2);
18911892}
18921893
1894+ expr Memory::blockPropertiesRefined (const Pointer &src, const Pointer &tgt)
1895+ const {
1896+ expr aligned (true );
1897+ expr src_align = src.blockAlignment ();
1898+ expr tgt_align = tgt.blockAlignment ();
1899+ // if they are both non-const, then the condition holds per the precondition
1900+ if (src_align.isConst () || tgt_align.isConst ())
1901+ aligned = src_align.ule (tgt_align);
1902+
1903+ return src.isBlockAlive () == tgt.isBlockAlive () &&
1904+ src.blockSize () == tgt.blockSize () &&
1905+ src.getAllocType () == tgt.getAllocType () &&
1906+ aligned;
1907+ }
1908+
18931909expr Memory::blockRefined (const Pointer &src, const Pointer &tgt, unsigned bid,
1910+ optional<unsigned > bid_other,
18941911 set<expr> &undef) const {
18951912 unsigned bytes_per_byte = bits_byte / 8 ;
18961913
@@ -1905,29 +1922,18 @@ expr Memory::blockRefined(const Pointer &src, const Pointer &tgt, unsigned bid,
19051922 expr off_expr = expr::mkUInt (off, Pointer::bitsShortOffset ());
19061923 val_refines
19071924 &= (ptr_offset == off_expr).implies (
1908- blockValRefined (tgt.getMemory (), bid, false , off_expr, undef));
1925+ blockValRefined (tgt.getMemory (), bid, bid_other , off_expr, undef));
19091926 }
19101927 } else {
19111928 val_refines
19121929 = src.getOffsetSizet ().ult (src.blockSizeOffsetT ()).implies (
1913- blockValRefined (tgt.getMemory (), bid, false , ptr_offset, undef));
1930+ blockValRefined (tgt.getMemory (), bid, bid_other , ptr_offset, undef));
19141931 }
19151932
19161933 assert (src.isWritable ().eq (tgt.isWritable ()));
19171934
1918- expr aligned (true );
1919- expr src_align = src.blockAlignment ();
1920- expr tgt_align = tgt.blockAlignment ();
1921- // if they are both non-const, then the condition holds per the precondition
1922- if (src_align.isConst () || tgt_align.isConst ())
1923- aligned = src_align.ule (tgt_align);
1924-
19251935 expr alive = src.isBlockAlive ();
1926- return alive == tgt.isBlockAlive () &&
1927- blk_size == tgt.blockSize () &&
1928- src.getAllocType () == tgt.getAllocType () &&
1929- aligned &&
1930- alive.implies (val_refines);
1936+ return blockPropertiesRefined (src, tgt) && alive.implies (val_refines);
19311937}
19321938
19331939tuple<expr, Pointer, set<expr>>
@@ -1958,7 +1964,8 @@ Memory::refined(const Memory &other, bool skip_constants,
19581964 Pointer q (other, p ());
19591965 if (p.isByval ().isTrue () && q.isByval ().isTrue ())
19601966 continue ;
1961- ret &= (ptr_bid == bid_expr).implies (blockRefined (p, q, bid, undef_vars));
1967+ ret &= (ptr_bid == bid_expr)
1968+ .implies (blockRefined (p, q, bid, nullopt , undef_vars));
19621969 }
19631970
19641971 // restrict refinement check to set of request blocks
0 commit comments