Skip to content

Commit

Permalink
code simpl
Browse files Browse the repository at this point in the history
  • Loading branch information
nunoplopes committed Dec 8, 2023
1 parent b8ad3d2 commit 7a337a1
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions tools/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,23 +528,20 @@ check_refinement(Errors &errs, const Transform &t, State &src_state,
return;
}

{
if (auto sink_src = src_state.sinkDomain(false);
!sink_src.isTrue() && check_expr(axioms_expr && !sink_src).isUnsat()) {
errs.add("The source program doesn't reach a return instruction.\n"
"Consider increasing the unroll factor if it has loops", false);
return;
}

auto sink_tgt = tgt_state.sinkDomain(true);
if (!sink_tgt.isTrue() && check_expr(axioms_expr && !sink_tgt).isUnsat()) {
errs.add("The target program doesn't reach a return instruction.\n"
"Consider increasing the unroll factor if it has loops", false);
return;
}
if (auto sink_src = src_state.sinkDomain(false);
!sink_src.isTrue() && check_expr(axioms_expr && !sink_src).isUnsat()) {
errs.add("The source program doesn't reach a return instruction.\n"
"Consider increasing the unroll factor if it has loops", false);
return;
}

pre_tgt &= !sink_tgt;
if (auto sink_tgt = tgt_state.sinkDomain(false);
!sink_tgt.isTrue() && check_expr(axioms_expr && !sink_tgt).isUnsat()) {
errs.add("The target program doesn't reach a return instruction.\n"
"Consider increasing the unroll factor if it has loops", false);
return;
}
pre_tgt &= !tgt_state.sinkDomain(true);

expr pre, pre_src_forall;
{
Expand Down Expand Up @@ -670,9 +667,8 @@ check_refinement(Errors &errs, const Transform &t, State &src_state,
// 6. Check memory
auto &src_mem = src_state.returnMemory();
auto &tgt_mem = tgt_state.returnMemory();
auto [memory_cnstr0, ptr_refinement0, mem_undef]
auto [memory_cnstr, ptr_refinement, mem_undef]
= src_mem.refined(tgt_mem, false);
auto &ptr_refinement = ptr_refinement0;
qvars.insert(mem_undef.begin(), mem_undef.end());

auto print_ptr_load = [&](ostream &s, const Model &m) {
Expand All @@ -683,8 +679,8 @@ check_refinement(Errors &errs, const Transform &t, State &src_state,
<< "\nTarget value: " << Byte(tgt_mem, m[tgt_mem.raw_load(p, undef)()]);
};

CHECK(dom && !(memory_cnstr0.isTrue() ? memory_cnstr0
: value_cnstr && memory_cnstr0),
CHECK(dom && !(memory_cnstr.isTrue() ? memory_cnstr
: value_cnstr && memory_cnstr),
print_ptr_load, "Mismatch in memory");

#undef CHECK
Expand Down

0 comments on commit 7a337a1

Please sign in to comment.