From 6495006b74655554b4d3d18f5c6221facaa8b67c Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 9 Nov 2020 16:49:57 -0500 Subject: opt: Check optlevel before removing unreachable expressions --- opt.c | 6 ++++-- 1 file 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; } -- cgit v1.2.3