+/* Check if data->u2 has an element living in the same space as *entry.
+ * If so, call data->fn on the two elements and add the result to
+ * data->res.
+ */
+static int match_bin_entry(void **entry, void *user)
+{
+ S(UNION,match_bin_data) *data = user;
+ uint32_t hash;
+ struct isl_hash_table_entry *entry2;
+ isl_space *space;
+ PART *part = *entry;
+
+ space = FN(PART,get_space)(part);
+ hash = isl_space_get_hash(space);
+ entry2 = isl_hash_table_find(data->u2->dim->ctx, &data->u2->table,
+ hash, &has_dim, space, 0);
+ isl_space_free(space);
+ if (!entry2)
+ return 0;
+
+ part = FN(PART, copy)(part);
+ part = data->fn(part, FN(PART, copy)(entry2->data));
+
+ if (DEFAULT_IS_ZERO) {
+ int empty;
+
+ empty = FN(PART,IS_ZERO)(part);
+ if (empty < 0) {
+ FN(PART,free)(part);
+ return -1;
+ }
+ if (empty) {
+ FN(PART,free)(part);
+ return 0;
+ }
+ }
+
+ data->res = FN(FN(UNION,add),PARTS)(data->res, part);
+
+ return 0;
+}
+