void
do_write_out(int ignore)
{
+ difficulty_cache.clear();
force_writeout = true;
}
if (values.size() > 0)
{
- if (values.size() > 10)
+ const int old_size = values.size();
+ if (old_size > 10)
removeDuplicates(expressions);
+ discarded += (old_size - values.size());
+
// Put the functions in buckets based on their results on the values.
HASHMAP<uint64_t, ASTVec> map;
for (int i = 0; i < expressions.size(); i++)
if (!r)
continue;
- cout << "Discovered a new rule.";
- cout << f << t;
- cout << getDifficulty(f) << " to " << getDifficulty(t) << endl;
-
Rewrite_rule rr(mgr, f, t, checktime);
- if (!rr.timedCheck(10000))
+ VariableAssignment bad;
+ if (!rr.timedCheck(10000,bad))
{
+ vector<VariableAssignment> ass;
+ ass.push_back(bad);
+
cout << "Rule failed extended verification.";
- continue;
+
+ // If it can fit into an unsigned. Split the list on it.
+ if (sizeof(unsigned int) * 8 > bad.getV().GetValueWidth())
+ {
+ findRewrites(equiv, ass, depth + 1);
+ return;
+ }
+ else
+ continue;
}
+
+ cout << "Discovered a new rule.";
+ cout << f << t;
+ cout << getDifficulty(f) << " to " << getDifficulty(t) << endl;
+
cout << "Verified Rule to: " << rr.getVerifiedToBits() << " bits" << endl;
cout << "------";
// Sometimes it doesn't. Not sure why..
assert(t == rewrite_system.rewriteNode(f));
-
equiv[i] = rewrite_system.rewriteNode(equiv[i]);
equiv[j] = rewrite_system.rewriteNode(equiv[j]);
+ if (equiv[i] == equiv[j])
+ equiv[j]= mgr->ASTUndefined;
}
else if (!bad)
{
for (Rewrite_system::RewriteRuleContainer::iterator it = rewrite_system.begin(); it != rewrite_system.end(); it++)
{
- if ((*it).timedCheck(timeout_ms))
+ VariableAssignment bad;
+ if ((*it).timedCheck(timeout_ms,bad))
{
it->writeOut(cout); // omit failed.
cerr << getDifficulty(it->getFrom()) << " " << getDifficulty(it->getTo());
// Tests for the timeout amount of time. FALSE if a bad instance was found. Otherwise true.
bool
- timedCheck(int timeout_ms)
+ timedCheck(int timeout_ms, VariableAssignment& bad)
{
- VariableAssignment assignment;
-
mgr->soft_timeout_expired = false;
itimerval timeout;
signal(SIGVTALRM, soft_time_out);
int checked_to = 0;
// Start it verifying where we left off..
- for (int i = std::max(bits, getVerifiedToBits() + 1); i < 1024; i++)
+ for (int new_bitwidth = std::max(bits, getVerifiedToBits() + 1); new_bitwidth < 1024; new_bitwidth++)
{
//cout << i << " ";
ASTVec children;
children.push_back(to);
const ASTNode n = mgr->hashingNodeFactory->CreateNode(EQ, children);
- const ASTNode& widened = widen(n, i);
+ const ASTNode& widened = widen(n, new_bitwidth);
if (widened == mgr->ASTUndefined)
{
cout << "cannot widen";
cerr << from << to;
}
- bool result = isConstant(widened, assignment, i);
+ bool result = isConstant(widened, bad, new_bitwidth);
if (!result && !mgr->soft_timeout_expired)
{
// not a constant, and not timed out!
- cerr << "FAILED:" << endl << i << from << to;
+ cerr << "FAILED:" << endl << new_bitwidth << from << to;
writeOut(cerr);
// The timer might not have expired yet.
if (mgr->soft_timeout_expired)
break;
- checked_to = i;
+ checked_to = new_bitwidth;
}
if (getVerifiedToBits() <= checked_to)