From d5f73bf3882c164aa53acbe80cef74cbaaabf25e Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 5 Sep 2022 22:00:00 +0300 Subject: [PATCH] Skip op1 of CONTROL nodes --- ir_sccp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ir_sccp.c b/ir_sccp.c index b6fb403..8ba5755 100644 --- a/ir_sccp.c +++ b/ir_sccp.c @@ -567,7 +567,9 @@ int ir_sccp(ir_ctx *ctx) flags = ir_op_flags[insn->op]; n = ir_input_edges_count(ctx, insn); - for (j = 1; j <= n; j++) { + /* first input is source control (we may skip it) */ + IR_ASSERT(n == 0 || IR_OPND_KIND(flags, 1) == IR_OPND_CONTROL); + for (j = 2; j <= n; j++) { if (IR_OPND_KIND(flags, j) == IR_OPND_DATA || IR_OPND_KIND(flags, j) == IR_OPND_VAR) { use = insn->ops[j]; if (use > 0 && IR_IS_TOP(use) && !ir_bitqueue_in(&worklist, use)) {