@@ -290,20 +290,21 @@ literalt bv_utilst::carry(literalt a, literalt b, literalt c)
290
290
}
291
291
}
292
292
293
- void bv_utilst::adder (
293
+ literalt bv_utilst::adder (
294
294
bvt &sum,
295
295
const bvt &op,
296
- literalt carry_in,
297
- literalt &carry_out)
296
+ literalt carry_in)
298
297
{
299
298
PRECONDITION (sum.size () == op.size ());
300
299
301
- carry_out= carry_in;
300
+ literalt carry_out = carry_in;
302
301
303
302
for (std::size_t i=0 ; i<sum.size (); i++)
304
303
{
305
304
sum[i] = full_adder (sum[i], op[i], carry_out, carry_out);
306
305
}
306
+
307
+ return carry_out;
307
308
}
308
309
309
310
literalt bv_utilst::carry_out (
@@ -337,12 +338,12 @@ bvt bv_utilst::add_sub(const bvt &op0, const bvt &op1, bool subtract)
337
338
PRECONDITION (op0.size () == op1.size ());
338
339
339
340
literalt carry_in=const_literal (subtract);
340
- literalt carry_out;
341
341
342
342
bvt result=op0;
343
343
bvt tmp_op1=subtract?inverted (op1):op1;
344
344
345
- adder (result, tmp_op1, carry_in, carry_out);
345
+ // we ignore the carry-out
346
+ (void )adder (result, tmp_op1, carry_in);
346
347
347
348
return result;
348
349
}
@@ -353,9 +354,9 @@ bvt bv_utilst::add_sub(const bvt &op0, const bvt &op1, literalt subtract)
353
354
select (subtract, inverted (op1), op1);
354
355
355
356
bvt result=op0;
356
- literalt carry_out;
357
357
358
- adder (result, op1_sign_applied, subtract, carry_out);
358
+ // we ignore the carry-out
359
+ (void )adder (result, op1_sign_applied, subtract);
359
360
360
361
return result;
361
362
}
@@ -371,12 +372,11 @@ bvt bv_utilst::saturating_add_sub(
371
372
rep == representationt::SIGNED || rep == representationt::UNSIGNED);
372
373
373
374
literalt carry_in = const_literal (subtract);
374
- literalt carry_out;
375
375
376
376
bvt add_sub_result = op0;
377
377
bvt tmp_op1 = subtract ? inverted (op1) : op1;
378
378
379
- adder (add_sub_result, tmp_op1, carry_in, carry_out );
379
+ literalt carry_out = adder (add_sub_result, tmp_op1, carry_in);
380
380
381
381
bvt result;
382
382
result.reserve (add_sub_result.size ());
@@ -496,8 +496,8 @@ void bv_utilst::adder_no_overflow(
496
496
literalt sign_the_same=
497
497
prop.lequal (sum[sum.size ()-1 ], tmp_op[tmp_op.size ()-1 ]);
498
498
499
- literalt carry;
500
- adder (sum, tmp_op, const_literal (subtract), carry );
499
+ // we ignore the carry-out
500
+ ( void ) adder (sum, tmp_op, const_literal (subtract));
501
501
502
502
// result of addition in sum
503
503
prop.l_set_to_false (
@@ -508,18 +508,14 @@ void bv_utilst::adder_no_overflow(
508
508
INVARIANT (
509
509
rep == representationt::UNSIGNED,
510
510
" representation has either value signed or unsigned" );
511
- literalt carry_out;
512
- adder (sum, tmp_op, const_literal (subtract), carry_out);
511
+ literalt carry_out = adder (sum, tmp_op, const_literal (subtract));
513
512
prop.l_set_to (carry_out, subtract);
514
513
}
515
514
}
516
515
517
516
void bv_utilst::adder_no_overflow (bvt &sum, const bvt &op)
518
517
{
519
- literalt carry_out=const_literal (false );
520
-
521
- adder (sum, op, carry_out, carry_out);
522
-
518
+ literalt carry_out = adder (sum, op, const_literal (false ));
523
519
prop.l_set_to_false (carry_out); // enforce no overflow
524
520
}
525
521
0 commit comments