From 84a4b4259a0ea246f82e0d8a3d79032af75b5267 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 18 Sep 2024 09:09:56 +0300 Subject: [PATCH] Set IR_BB_LOOP_WITH_ENTRY flag for all enclosing loops containig ENTRY instruction. Previoudly we set IR_BB_LOOP_WITH_ENTRY only for the deepest loop. --- ir_cfg.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ir_cfg.c b/ir_cfg.c index ecb98ad..c2893dc 100644 --- a/ir_cfg.c +++ b/ir_cfg.c @@ -1033,6 +1033,20 @@ int ir_find_loops(ir_ctx *ctx) bb->loop_depth = loop_depth; if (bb->flags & (IR_BB_ENTRY|IR_BB_LOOP_WITH_ENTRY)) { loop->flags |= IR_BB_LOOP_WITH_ENTRY; + if (loop_depth > 1) { + /* Set IR_BB_LOOP_WITH_ENTRY flag for all the enclosing loops */ + bb = &blocks[loop->loop_header]; + while (1) { + if (bb->flags & IR_BB_LOOP_WITH_ENTRY) { + break; + } + bb->flags |= IR_BB_LOOP_WITH_ENTRY; + if (bb->loop_depth == 1) { + break; + } + bb = &blocks[loop->loop_header]; + } + } } } }