diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2020-11-09 16:49:57 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2020-11-09 16:49:57 -0500 |
commit | 6495006b74655554b4d3d18f5c6221facaa8b67c (patch) | |
tree | 523f0108f4258fa1a7be1e572ae427db0bba04ac /opt.c | |
parent | 0e80632397f581380441a4165247cd46f4bfcda0 (diff) | |
download | bfs-6495006b74655554b4d3d18f5c6221facaa8b67c.tar.xz |
opt: Check optlevel before removing unreachable expressions
Diffstat (limited to 'opt.c')
-rw-r--r-- | opt.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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; } |