Skip to content

simplifier: erase 'all ones' out of bitand #1226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/util/simplify_expr_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ bool simplify_exprt::simplify_bitwise(exprt &expr)
result=false;
}

// now erase zeros out of bitor, bitxor
// now erase 'all zeros' out of bitor, bitxor

if(expr.id()==ID_bitor || expr.id()==ID_bitxor)
{
Expand All @@ -683,6 +683,28 @@ bool simplify_exprt::simplify_bitwise(exprt &expr)
}
}

// now erase 'all ones' out of bitand

if(expr.id()==ID_bitand)
{
for(exprt::operandst::iterator
it=expr.operands().begin();
it!=expr.operands().end();
) // no it++
{
if(it->is_constant() &&
id2string(to_constant_expr(*it).get_value()).find('0')==
std::string::npos &&
expr.operands().size()>1)
{
it=expr.operands().erase(it);
result=false;
}
else
it++;
}
}

// two operands that are syntactically the same

if(expr.operands().size()==2 &&
Expand Down