@@ -294,18 +294,18 @@ TEST(KnownBitsTest, SignBitUnknown) {
294
294
EXPECT_TRUE (Known.isSignUnknown ());
295
295
}
296
296
297
- TEST (KnownBitsTest, AbsDiffSpecialCase ) {
298
- // There are 2 implementation of absdiff - both are currently needed to cover
297
+ TEST (KnownBitsTest, ABDUSpecialCase ) {
298
+ // There are 2 implementations of abdu - both are currently needed to cover
299
299
// extra cases.
300
300
KnownBits LHS, RHS, Res;
301
301
302
- // absdiff (LHS,RHS) = sub(umax(LHS,RHS), umin(LHS,RHS)).
302
+ // abdu (LHS,RHS) = sub(umax(LHS,RHS), umin(LHS,RHS)).
303
303
// Actual: false (Inputs = 1011, 101?, Computed = 000?, Exact = 000?)
304
304
LHS.One = APInt (4 , 0b1011 );
305
305
RHS.One = APInt (4 , 0b1010 );
306
306
LHS.Zero = APInt (4 , 0b0100 );
307
307
RHS.Zero = APInt (4 , 0b0100 );
308
- Res = KnownBits::absdiff (LHS, RHS);
308
+ Res = KnownBits::abdu (LHS, RHS);
309
309
EXPECT_EQ (0b0000ul , Res.One .getZExtValue ());
310
310
EXPECT_EQ (0b1110ul , Res.Zero .getZExtValue ());
311
311
@@ -315,11 +315,37 @@ TEST(KnownBitsTest, AbsDiffSpecialCase) {
315
315
RHS.One = APInt (4 , 0b1000 );
316
316
LHS.Zero = APInt (4 , 0b0000 );
317
317
RHS.Zero = APInt (4 , 0b0111 );
318
- Res = KnownBits::absdiff (LHS, RHS);
318
+ Res = KnownBits::abdu (LHS, RHS);
319
319
EXPECT_EQ (0b0001ul , Res.One .getZExtValue ());
320
320
EXPECT_EQ (0b0000ul , Res.Zero .getZExtValue ());
321
321
}
322
322
323
+ TEST (KnownBitsTest, ABDSSpecialCase) {
324
+ // There are 2 implementations of abds - both are currently needed to cover
325
+ // extra cases.
326
+ KnownBits LHS, RHS, Res;
327
+
328
+ // abds(LHS,RHS) = sub(smax(LHS,RHS), smin(LHS,RHS)).
329
+ // Actual: false (Inputs = 1011, 10??, Computed = ????, Exact = 00??)
330
+ LHS.One = APInt (4 , 0b1011 );
331
+ RHS.One = APInt (4 , 0b1000 );
332
+ LHS.Zero = APInt (4 , 0b0100 );
333
+ RHS.Zero = APInt (4 , 0b0100 );
334
+ Res = KnownBits::abds (LHS, RHS);
335
+ EXPECT_EQ (0 , Res.One .getSExtValue ());
336
+ EXPECT_EQ (-4 , Res.Zero .getSExtValue ());
337
+
338
+ // find the common bits between sub(LHS,RHS) and sub(RHS,LHS).
339
+ // Actual: false (Inputs = ???1, 1000, Computed = ???1, Exact = 0??1)
340
+ LHS.One = APInt (4 , 0b0001 );
341
+ RHS.One = APInt (4 , 0b1000 );
342
+ LHS.Zero = APInt (4 , 0b0000 );
343
+ RHS.Zero = APInt (4 , 0b0111 );
344
+ Res = KnownBits::abds (LHS, RHS);
345
+ EXPECT_EQ (1 , Res.One .getSExtValue ());
346
+ EXPECT_EQ (0 , Res.Zero .getSExtValue ());
347
+ }
348
+
323
349
TEST (KnownBitsTest, BinaryExhaustive) {
324
350
testBinaryOpExhaustive (
325
351
[](const KnownBits &Known1, const KnownBits &Known2) {
@@ -359,10 +385,16 @@ TEST(KnownBitsTest, BinaryExhaustive) {
359
385
[](const APInt &N1, const APInt &N2) { return APIntOps::smin (N1, N2); });
360
386
testBinaryOpExhaustive (
361
387
[](const KnownBits &Known1, const KnownBits &Known2) {
362
- return KnownBits::absdiff (Known1, Known2);
388
+ return KnownBits::abdu (Known1, Known2);
363
389
},
364
390
[](const APInt &N1, const APInt &N2) { return APIntOps::abdu (N1, N2); },
365
391
checkCorrectnessOnlyBinary);
392
+ testBinaryOpExhaustive (
393
+ [](const KnownBits &Known1, const KnownBits &Known2) {
394
+ return KnownBits::abds (Known1, Known2);
395
+ },
396
+ [](const APInt &N1, const APInt &N2) { return APIntOps::abds (N1, N2); },
397
+ checkCorrectnessOnlyBinary);
366
398
testBinaryOpExhaustive (
367
399
[](const KnownBits &Known1, const KnownBits &Known2) {
368
400
return KnownBits::udiv (Known1, Known2);
0 commit comments