summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-11-09 16:49:57 -0500
committerTavian Barnes <tavianator@tavianator.com>2020-11-09 16:49:57 -0500
commit6495006b74655554b4d3d18f5c6221facaa8b67c (patch)
tree523f0108f4258fa1a7be1e572ae427db0bba04ac
parent0e80632397f581380441a4165247cd46f4bfcda0 (diff)
downloadbfs-6495006b74655554b4d3d18f5c6221facaa8b67c.tar.xz
opt: Check optlevel before removing unreachable expressions
-rw-r--r--opt.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/opt.c b/opt.c
index 9876f3d..8c516ea 100644
--- a/opt.c
+++ b/opt.c
@@ -801,10 +801,12 @@ static void infer_xtype_facts(struct opt_state *state, const struct expr *expr)
}
static struct expr *optimize_expr_recursive(struct opt_state *state, struct expr *expr) {
+ int optlevel = state->ctx->optlevel;
+
state->facts_when_true = state->facts;
state->facts_when_false = state->facts;
- if (facts_are_impossible(&state->facts)) {
+ if (optlevel >= 2 && facts_are_impossible(&state->facts)) {
debug_opt(state, 2, "reachability: %pe --> %pe\n", expr, &expr_false);
free_expr(expr);
expr = &expr_false;
@@ -885,7 +887,7 @@ static struct expr *optimize_expr_recursive(struct opt_state *state, struct expr
set_facts_impossible(&state->facts_when_true);
}
- if (state->ctx->optlevel < 2 || expr == &expr_true || expr == &expr_false) {
+ if (optlevel < 2 || expr == &expr_true || expr == &expr_false) {
goto done;
}