@@ -193,3 +193,73 @@ TEST(PresburgerSpaceTest, convertVarKind2) {
193
193
EXPECT_EQ (space.getId (VarKind::Symbol, 2 ), Identifier (&identifiers[1 ]));
194
194
EXPECT_EQ (space.getId (VarKind::Symbol, 3 ), Identifier (&identifiers[3 ]));
195
195
}
196
+
197
+ TEST (PresburgerSpaceTest, mergeAndAlignSymbols) {
198
+ PresburgerSpace space = PresburgerSpace::getRelationSpace (3 , 3 , 2 , 0 );
199
+ space.resetIds ();
200
+
201
+ PresburgerSpace otherSpace = PresburgerSpace::getRelationSpace (3 , 2 , 3 , 0 );
202
+ otherSpace.resetIds ();
203
+
204
+ // Attach identifiers.
205
+ int identifiers[7 ] = {0 , 1 , 2 , 3 , 4 , 5 , 6 };
206
+ int otherIdentifiers[8 ] = {10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 };
207
+
208
+ space.getId (VarKind::Domain, 0 ) = Identifier (&identifiers[0 ]);
209
+ space.getId (VarKind::Domain, 1 ) = Identifier (&identifiers[1 ]);
210
+ // Note the common identifier.
211
+ space.getId (VarKind::Domain, 2 ) = Identifier (&otherIdentifiers[2 ]);
212
+ space.getId (VarKind::Range, 0 ) = Identifier (&identifiers[2 ]);
213
+ space.getId (VarKind::Range, 1 ) = Identifier (&identifiers[3 ]);
214
+ space.getId (VarKind::Range, 2 ) = Identifier (&identifiers[4 ]);
215
+ space.getId (VarKind::Symbol, 0 ) = Identifier (&identifiers[5 ]);
216
+ space.getId (VarKind::Symbol, 1 ) = Identifier (&identifiers[6 ]);
217
+
218
+ otherSpace.getId (VarKind::Domain, 0 ) = Identifier (&otherIdentifiers[0 ]);
219
+ otherSpace.getId (VarKind::Domain, 1 ) = Identifier (&otherIdentifiers[1 ]);
220
+ otherSpace.getId (VarKind::Domain, 2 ) = Identifier (&otherIdentifiers[2 ]);
221
+ otherSpace.getId (VarKind::Range, 0 ) = Identifier (&otherIdentifiers[3 ]);
222
+ otherSpace.getId (VarKind::Range, 1 ) = Identifier (&otherIdentifiers[4 ]);
223
+ // Note the common identifier.
224
+ otherSpace.getId (VarKind::Symbol, 0 ) = Identifier (&identifiers[6 ]);
225
+ otherSpace.getId (VarKind::Symbol, 1 ) = Identifier (&otherIdentifiers[5 ]);
226
+ otherSpace.getId (VarKind::Symbol, 2 ) = Identifier (&otherIdentifiers[7 ]);
227
+
228
+ space.mergeAndAlignSymbols (otherSpace);
229
+
230
+ // Check if merge & align is successful.
231
+ // Check symbol var identifiers.
232
+ EXPECT_EQ (4u , space.getNumSymbolVars ());
233
+ EXPECT_EQ (4u , otherSpace.getNumSymbolVars ());
234
+ EXPECT_EQ (space.getId (VarKind::Symbol, 0 ), Identifier (&identifiers[5 ]));
235
+ EXPECT_EQ (space.getId (VarKind::Symbol, 1 ), Identifier (&identifiers[6 ]));
236
+ EXPECT_EQ (space.getId (VarKind::Symbol, 2 ), Identifier (&otherIdentifiers[5 ]));
237
+ EXPECT_EQ (space.getId (VarKind::Symbol, 3 ), Identifier (&otherIdentifiers[7 ]));
238
+ EXPECT_EQ (otherSpace.getId (VarKind::Symbol, 0 ), Identifier (&identifiers[5 ]));
239
+ EXPECT_EQ (otherSpace.getId (VarKind::Symbol, 1 ), Identifier (&identifiers[6 ]));
240
+ EXPECT_EQ (otherSpace.getId (VarKind::Symbol, 2 ),
241
+ Identifier (&otherIdentifiers[5 ]));
242
+ EXPECT_EQ (otherSpace.getId (VarKind::Symbol, 3 ),
243
+ Identifier (&otherIdentifiers[7 ]));
244
+ // Check that domain and range var identifiers are not affected.
245
+ EXPECT_EQ (3u , space.getNumDomainVars ());
246
+ EXPECT_EQ (3u , space.getNumRangeVars ());
247
+ EXPECT_EQ (space.getId (VarKind::Domain, 0 ), Identifier (&identifiers[0 ]));
248
+ EXPECT_EQ (space.getId (VarKind::Domain, 1 ), Identifier (&identifiers[1 ]));
249
+ EXPECT_EQ (space.getId (VarKind::Domain, 2 ), Identifier (&otherIdentifiers[2 ]));
250
+ EXPECT_EQ (space.getId (VarKind::Range, 0 ), Identifier (&identifiers[2 ]));
251
+ EXPECT_EQ (space.getId (VarKind::Range, 1 ), Identifier (&identifiers[3 ]));
252
+ EXPECT_EQ (space.getId (VarKind::Range, 2 ), Identifier (&identifiers[4 ]));
253
+ EXPECT_EQ (3u , otherSpace.getNumDomainVars ());
254
+ EXPECT_EQ (2u , otherSpace.getNumRangeVars ());
255
+ EXPECT_EQ (otherSpace.getId (VarKind::Domain, 0 ),
256
+ Identifier (&otherIdentifiers[0 ]));
257
+ EXPECT_EQ (otherSpace.getId (VarKind::Domain, 1 ),
258
+ Identifier (&otherIdentifiers[1 ]));
259
+ EXPECT_EQ (otherSpace.getId (VarKind::Domain, 2 ),
260
+ Identifier (&otherIdentifiers[2 ]));
261
+ EXPECT_EQ (otherSpace.getId (VarKind::Range, 0 ),
262
+ Identifier (&otherIdentifiers[3 ]));
263
+ EXPECT_EQ (otherSpace.getId (VarKind::Range, 1 ),
264
+ Identifier (&otherIdentifiers[4 ]));
265
+ }
0 commit comments