Skip to content

Commit 12cacab

Browse files
author
Daniel Kroening
committed
simplify_expr_if: result -> nochange
1 parent a2d7c1f commit 12cacab

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

src/util/simplify_expr_if.cpp

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ bool simplify_exprt::simplify_if_recursive(
9191
}
9292
}
9393

94-
bool result = true;
94+
bool no_change = true;
9595

9696
Forall_operands(it, expr)
97-
result = simplify_if_recursive(*it, cond, truth) && result;
97+
no_change = simplify_if_recursive(*it, cond, truth) && no_change;
9898

99-
return result;
99+
return no_change;
100100
}
101101

102102
bool simplify_exprt::simplify_if_conj(exprt &expr, const exprt &cond)
@@ -110,12 +110,12 @@ bool simplify_exprt::simplify_if_conj(exprt &expr, const exprt &cond)
110110
}
111111
}
112112

113-
bool result = true;
113+
bool no_change = true;
114114

115115
Forall_operands(it, expr)
116-
result = simplify_if_conj(*it, cond) && result;
116+
no_change = simplify_if_conj(*it, cond) && no_change;
117117

118-
return result;
118+
return no_change;
119119
}
120120

121121
bool simplify_exprt::simplify_if_disj(exprt &expr, const exprt &cond)
@@ -129,49 +129,49 @@ bool simplify_exprt::simplify_if_disj(exprt &expr, const exprt &cond)
129129
}
130130
}
131131

132-
bool result = true;
132+
bool no_change = true;
133133

134134
Forall_operands(it, expr)
135-
result = simplify_if_disj(*it, cond) && result;
135+
no_change = simplify_if_disj(*it, cond) && no_change;
136136

137-
return result;
137+
return no_change;
138138
}
139139

140140
bool simplify_exprt::simplify_if_branch(
141141
exprt &trueexpr,
142142
exprt &falseexpr,
143143
const exprt &cond)
144144
{
145-
bool tresult = true;
146-
bool fresult = true;
145+
bool tno_change = true;
146+
bool fno_change = true;
147147

148148
if(cond.id() == ID_and)
149149
{
150-
tresult = simplify_if_conj(trueexpr, cond) && tresult;
151-
fresult = simplify_if_recursive(falseexpr, cond, false) && fresult;
150+
tno_change = simplify_if_conj(trueexpr, cond) && tno_change;
151+
fno_change = simplify_if_recursive(falseexpr, cond, false) && fno_change;
152152
}
153153
else if(cond.id() == ID_or)
154154
{
155-
tresult = simplify_if_recursive(trueexpr, cond, true) && tresult;
156-
fresult = simplify_if_disj(falseexpr, cond) && fresult;
155+
tno_change = simplify_if_recursive(trueexpr, cond, true) && tno_change;
156+
fno_change = simplify_if_disj(falseexpr, cond) && fno_change;
157157
}
158158
else
159159
{
160-
tresult = simplify_if_recursive(trueexpr, cond, true) && tresult;
161-
fresult = simplify_if_recursive(falseexpr, cond, false) && fresult;
160+
tno_change = simplify_if_recursive(trueexpr, cond, true) && tno_change;
161+
fno_change = simplify_if_recursive(falseexpr, cond, false) && fno_change;
162162
}
163163

164-
if(!tresult)
164+
if(!tno_change)
165165
trueexpr = simplify_rec(trueexpr); // recursive call
166-
if(!fresult)
166+
if(!fno_change)
167167
falseexpr = simplify_rec(falseexpr); // recursive call
168168

169-
return tresult && fresult;
169+
return tno_change && fno_change;
170170
}
171171

172172
bool simplify_exprt::simplify_if_cond(exprt &expr)
173173
{
174-
bool result = true;
174+
bool no_change = true;
175175
bool tmp = false;
176176

177177
while(!tmp)
@@ -201,10 +201,10 @@ bool simplify_exprt::simplify_if_cond(exprt &expr)
201201
if(!tmp)
202202
expr = simplify_rec(expr); // recursive call
203203

204-
result = tmp && result;
204+
no_change = tmp && no_change;
205205
}
206206

207-
return result;
207+
return no_change;
208208
}
209209

210210
bool simplify_exprt::simplify_if_preorder(if_exprt &expr)
@@ -213,14 +213,14 @@ bool simplify_exprt::simplify_if_preorder(if_exprt &expr)
213213
exprt &truevalue = expr.true_case();
214214
exprt &falsevalue = expr.false_case();
215215

216-
bool result = true;
216+
bool no_change = true;
217217

218218
// we first want to look at the condition
219219
auto r_cond = simplify_rec(cond);
220220
if(r_cond.has_changed())
221221
{
222222
cond = r_cond.expr;
223-
result = false;
223+
no_change = false;
224224
}
225225

226226
// 1 ? a : b -> a and 0 ? a : b -> b
@@ -240,7 +240,7 @@ bool simplify_exprt::simplify_if_preorder(if_exprt &expr)
240240
tmp.swap(cond.op0());
241241
cond.swap(tmp);
242242
truevalue.swap(falsevalue);
243-
result = false;
243+
no_change = false;
244244
}
245245

246246
#ifdef USE_LOCAL_REPLACE_MAP
@@ -264,7 +264,7 @@ bool simplify_exprt::simplify_if_preorder(if_exprt &expr)
264264
if(r_truevalue.has_changed())
265265
{
266266
truevalue = r_truevalue.expr;
267-
result = false;
267+
no_change = false;
268268
}
269269

270270
local_replace_map = map_before;
@@ -287,7 +287,7 @@ bool simplify_exprt::simplify_if_preorder(if_exprt &expr)
287287
if(r_falsevalue.has_changed())
288288
{
289289
falsevalue = r_falsevalue.expr;
290-
result = false;
290+
no_change = false;
291291
}
292292

293293
local_replace_map.swap(map_before);
@@ -296,13 +296,13 @@ bool simplify_exprt::simplify_if_preorder(if_exprt &expr)
296296
if(r_truevalue.has_changed())
297297
{
298298
truevalue = r_truevalue.expr;
299-
result = false;
299+
no_change = false;
300300
}
301301
auto r_falsevalue = simplify_rec(falsevalue);
302302
if(r_falsevalue.has_changed())
303303
{
304304
falsevalue = r_falsevalue.expr;
305-
result = false;
305+
no_change = false;
306306
}
307307
#endif
308308
}
@@ -312,17 +312,17 @@ bool simplify_exprt::simplify_if_preorder(if_exprt &expr)
312312
if(r_truevalue.has_changed())
313313
{
314314
truevalue = r_truevalue.expr;
315-
result = false;
315+
no_change = false;
316316
}
317317
auto r_falsevalue = simplify_rec(falsevalue);
318318
if(r_falsevalue.has_changed())
319319
{
320320
falsevalue = r_falsevalue.expr;
321-
result = false;
321+
no_change = false;
322322
}
323323
}
324324

325-
return result;
325+
return no_change;
326326
}
327327

328328
simplify_exprt::resultt<> simplify_exprt::simplify_if(const if_exprt &expr)
@@ -334,8 +334,8 @@ simplify_exprt::resultt<> simplify_exprt::simplify_if(const if_exprt &expr)
334334
if(do_simplify_if)
335335
{
336336
#if 0
337-
result = simplify_if_cond(cond) && result;
338-
result = simplify_if_branch(truevalue, falsevalue, cond) && result;
337+
no_change = simplify_if_cond(cond) && no_change;
338+
no_change = simplify_if_branch(truevalue, falsevalue, cond) && no_change;
339339
#endif
340340

341341
if(expr.type() == bool_typet())

0 commit comments

Comments
 (0)