helper function for comparing collections of definition points

This commit is contained in:
Vern Paxson 2021-02-27 11:32:06 -08:00
parent b581c6435e
commit ec97c9b042
2 changed files with 23 additions and 0 deletions

View file

@ -253,6 +253,27 @@ void Reducer::TrackExprReplacement(const Expr* orig, const Expr* e)
}
bool same_DPs(const DefPoints* dp1, const DefPoints* dp2)
{
if ( dp1 == dp2 )
return true;
if ( ! dp1 || ! dp2 )
return false;
// Given how we construct DPs, they should be element-by-element
// equivalent; we don't have to worry about reordering.
if ( dp1->length() != dp2->length() )
return false;
for ( auto i = 0; i < dp1->length(); ++i )
if ( ! (*dp1)[i].SameAs((*dp2)[i]) )
return false;
return true;
}
const Expr* non_reduced_perp;
bool checking_reduction;

View file

@ -214,6 +214,8 @@ protected:
const DefSetsMgr* mgr = nullptr;
};
extern bool same_DPs(const DefPoints* dp1, const DefPoints* dp2);
// Used for debugging, to communicate which expression wasn't
// reduced when we expected them all to be.
extern const Expr* non_reduced_perp;