Skip to content

Commit 12b20c3

Browse files
author
Daniel Kroening
authored
Merge pull request #4856 from diffblue/simplifier_result
Cleanup (&fix) simplifier result
2 parents 305f98e + a7adae4 commit 12b20c3

File tree

5 files changed

+71
-71
lines changed

5 files changed

+71
-71
lines changed

src/util/simplify_expr_array.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Author: Daniel Kroening, [email protected]
1717

1818
bool simplify_exprt::simplify_index(exprt &expr)
1919
{
20-
bool result=true;
20+
bool no_change = true;
2121

2222
// extra arithmetic optimizations
2323
const exprt &index=to_index_expr(expr).index();
@@ -32,15 +32,15 @@ bool simplify_exprt::simplify_index(exprt &expr)
3232
{
3333
exprt tmp=index.op0().op0();
3434
expr.op1()=tmp;
35-
result=false;
35+
no_change = false;
3636
}
3737
else if(index.op0().id()==ID_mult &&
3838
index.op0().operands().size()==2 &&
3939
index.op0().op0()==index.op1())
4040
{
4141
exprt tmp=index.op0().op1();
4242
expr.op1()=tmp;
43-
result=false;
43+
no_change = false;
4444
}
4545
}
4646

@@ -225,5 +225,5 @@ bool simplify_exprt::simplify_index(exprt &expr)
225225
return false;
226226
}
227227

228-
return result;
228+
return no_change;
229229
}

src/util/simplify_expr_boolean.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ bool simplify_exprt::simplify_boolean(exprt &expr)
4444
}
4545
else if(expr.id()==ID_xor)
4646
{
47-
bool result=true;
47+
bool no_change = true;
4848

4949
bool negate=false;
5050

@@ -67,7 +67,7 @@ bool simplify_exprt::simplify_boolean(exprt &expr)
6767
if(erase)
6868
{
6969
it=operands.erase(it);
70-
result=false;
70+
no_change = false;
7171
}
7272
else
7373
it++;
@@ -87,13 +87,13 @@ bool simplify_exprt::simplify_boolean(exprt &expr)
8787
return false;
8888
}
8989

90-
return result;
90+
return no_change;
9191
}
9292
else if(expr.id()==ID_and || expr.id()==ID_or)
9393
{
9494
std::unordered_set<exprt, irep_hash> expr_set;
9595

96-
bool result=true;
96+
bool no_change = true;
9797

9898
for(exprt::operandst::const_iterator it=operands.begin();
9999
it!=operands.end();)
@@ -122,7 +122,7 @@ bool simplify_exprt::simplify_boolean(exprt &expr)
122122
if(erase)
123123
{
124124
it=operands.erase(it);
125-
result=false;
125+
no_change = false;
126126
}
127127
else
128128
it++;
@@ -151,7 +151,7 @@ bool simplify_exprt::simplify_boolean(exprt &expr)
151151
return false;
152152
}
153153

154-
return result;
154+
return no_change;
155155
}
156156

157157
return true;

src/util/simplify_expr_int.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ bool simplify_exprt::simplify_mult(exprt &expr)
166166
exprt::operandst &operands=expr.operands();
167167

168168
// result of the simplification
169-
bool result = true;
169+
bool no_change = true;
170170

171171
// position of the constant
172172
exprt::operandst::iterator constant;
@@ -226,7 +226,7 @@ bool simplify_exprt::simplify_mult(exprt &expr)
226226
if(do_erase)
227227
{
228228
it=operands.erase(it);
229-
result = false;
229+
no_change = false;
230230
}
231231
else
232232
it++; // move to the next operand
@@ -246,7 +246,7 @@ bool simplify_exprt::simplify_mult(exprt &expr)
246246
exprt product(operands.front());
247247
expr.swap(product);
248248

249-
result = false;
249+
no_change = false;
250250
}
251251
else
252252
{
@@ -255,7 +255,7 @@ bool simplify_exprt::simplify_mult(exprt &expr)
255255
{
256256
// just delete it
257257
operands.erase(constant);
258-
result=false;
258+
no_change = false;
259259

260260
if(operands.size()==1)
261261
{
@@ -265,7 +265,7 @@ bool simplify_exprt::simplify_mult(exprt &expr)
265265
}
266266
}
267267

268-
return result;
268+
return no_change;
269269
}
270270

271271
bool simplify_exprt::simplify_div(exprt &expr)
@@ -428,7 +428,7 @@ bool simplify_exprt::simplify_plus(exprt &expr)
428428
if(!is_number(plus_expr.type()) && plus_expr.type().id() != ID_pointer)
429429
return true;
430430

431-
bool result=true;
431+
bool no_change = true;
432432

433433
exprt::operandst &operands=expr.operands();
434434

@@ -506,7 +506,7 @@ bool simplify_exprt::simplify_plus(exprt &expr)
506506
to_constant_expr(*it)))
507507
{
508508
*it=from_integer(0, it->type());
509-
result=false;
509+
no_change = false;
510510
}
511511
}
512512
}
@@ -539,7 +539,7 @@ bool simplify_exprt::simplify_plus(exprt &expr)
539539
*(itm->second)=from_integer(0, expr.type());
540540
*it=from_integer(0, expr.type());
541541
expr_map.erase(itm);
542-
result=false;
542+
no_change = false;
543543
}
544544
}
545545

@@ -554,7 +554,7 @@ bool simplify_exprt::simplify_plus(exprt &expr)
554554
if(is_number(it->type()) && it->is_zero())
555555
{
556556
it=operands.erase(it);
557-
result=false;
557+
no_change = false;
558558
}
559559
else
560560
it++;
@@ -573,7 +573,7 @@ bool simplify_exprt::simplify_plus(exprt &expr)
573573
return false;
574574
}
575575

576-
return result;
576+
return no_change;
577577
}
578578

579579
bool simplify_exprt::simplify_minus(exprt &expr)
@@ -694,7 +694,7 @@ bool simplify_exprt::simplify_bitwise(exprt &expr)
694694
}
695695
}
696696

697-
bool result=true;
697+
bool no_change = true;
698698

699699
// try to merge constants
700700

@@ -740,7 +740,7 @@ bool simplify_exprt::simplify_bitwise(exprt &expr)
740740
expr.operands().erase(expr.operands().begin());
741741
expr.op0().swap(new_op);
742742

743-
result=false;
743+
no_change = false;
744744
}
745745

746746
// now erase 'all zeros' out of bitor, bitxor
@@ -755,7 +755,7 @@ bool simplify_exprt::simplify_bitwise(exprt &expr)
755755
if(it->is_zero() && expr.operands().size()>1)
756756
{
757757
it=expr.operands().erase(it);
758-
result=false;
758+
no_change = false;
759759
}
760760
else
761761
it++;
@@ -779,7 +779,7 @@ bool simplify_exprt::simplify_bitwise(exprt &expr)
779779
expr.operands().size() > 1)
780780
{
781781
it=expr.operands().erase(it);
782-
result=false;
782+
no_change = false;
783783
}
784784
else
785785
it++;
@@ -814,7 +814,7 @@ bool simplify_exprt::simplify_bitwise(exprt &expr)
814814
return false;
815815
}
816816

817-
return result;
817+
return no_change;
818818
}
819819

820820
bool simplify_exprt::simplify_extractbit(exprt &expr)
@@ -853,7 +853,7 @@ bool simplify_exprt::simplify_extractbit(exprt &expr)
853853

854854
bool simplify_exprt::simplify_concatenation(exprt &expr)
855855
{
856-
bool result=true;
856+
bool no_change = true;
857857

858858
if(is_bitvector_type(expr.type()))
859859
{
@@ -865,7 +865,7 @@ bool simplify_exprt::simplify_concatenation(exprt &expr)
865865
{
866866
const bool value = op.is_true();
867867
op = from_integer(value, unsignedbv_typet(1));
868-
result = false;
868+
no_change = false;
869869
}
870870
}
871871

@@ -899,7 +899,7 @@ bool simplify_exprt::simplify_concatenation(exprt &expr)
899899
to_bitvector_type(opi.type()).set_width(new_width);
900900
// erase opn
901901
expr.operands().erase(expr.operands().begin()+i+1);
902-
result = false;
902+
no_change = false;
903903
}
904904
else
905905
i++;
@@ -930,7 +930,7 @@ bool simplify_exprt::simplify_concatenation(exprt &expr)
930930
opi.type().id(ID_verilog_unsignedbv);
931931
// erase opn
932932
expr.operands().erase(expr.operands().begin()+i+1);
933-
result = false;
933+
no_change = false;
934934
}
935935
else
936936
i++;
@@ -943,10 +943,10 @@ bool simplify_exprt::simplify_concatenation(exprt &expr)
943943
exprt tmp;
944944
tmp.swap(expr.op0());
945945
expr.swap(tmp);
946-
result=false;
946+
no_change = false;
947947
}
948948

949-
return result;
949+
return no_change;
950950
}
951951

952952
bool simplify_exprt::simplify_shifts(exprt &expr)
@@ -1530,23 +1530,23 @@ bool simplify_exprt::eliminate_common_addends(
15301530

15311531
if(op0.id()==ID_plus)
15321532
{
1533-
bool result=true;
1533+
bool no_change = true;
15341534

15351535
Forall_operands(it, op0)
15361536
if(!eliminate_common_addends(*it, op1))
1537-
result=false;
1537+
no_change = false;
15381538

1539-
return result;
1539+
return no_change;
15401540
}
15411541
else if(op1.id()==ID_plus)
15421542
{
1543-
bool result=true;
1543+
bool no_change = true;
15441544

15451545
Forall_operands(it, op1)
15461546
if(!eliminate_common_addends(op0, *it))
1547-
result=false;
1547+
no_change = false;
15481548

1549-
return result;
1549+
return no_change;
15501550
}
15511551
else if(op0==op1)
15521552
{

0 commit comments

Comments
 (0)