This series is a preparatory step for some other optimzations but is quite valuable in itself. It adds a new phase of CFG CFG simplification before any other simplifications. To be effective this pahse needs some other changes: * phi-sources & phi-nodes must be handled specifically whne merinf BBs. * some missing REPEAT_CFG_CLEANUP must be added * simplify_memops() must be called unconditionally These changes slightly decrease the number of 'context imbalance' warnings (32 less on a total of 995 warnings) and have otherwise a significant effect on the size of the generated IR (~0.4%). Luc Van Oostenryck (8): testcase: avoid UNDEF cfg: add testcase for phi-adjusting during BB merge cfg: extract merge_bb() from pack_basic_blocks() cfg: adjust phi-sources when merging BBs cfg: adjust phi-nodes when merging BBs cfg: add missing REPEAT_CFG_CLEANUP cfg: call simplify_memops() unconditionally. cfg: early CFG simplification flow.c | 201 ++++++++++++++++--- flow.h | 1 + linearize.c | 1 + memops.c | 2 + optimize.c | 9 +- simplify.c | 2 +- validation/call-inlined.c | 4 + validation/expand/builtin_constant_inline0.c | 1 + validation/inline_base0.c | 3 + validation/linear/builtin_unreachable0.c | 4 +- validation/linear/builtin_unreachable1.c | 4 +- validation/linear/call-inline.c | 2 +- validation/mem2reg/cond-expr.c | 4 +- validation/mem2reg/cond-expr5.c | 5 +- validation/optim/cse-size.c | 5 +- validation/optim/memops-missed01.c | 23 +++ validation/optim/memops-missed02.c | 14 ++ validation/optim/merge_bbe-adjust_phi.c | 23 +++ 18 files changed, 269 insertions(+), 39 deletions(-) create mode 100644 validation/optim/memops-missed01.c create mode 100644 validation/optim/memops-missed02.c create mode 100644 validation/optim/merge_bbe-adjust_phi.c -- 2.29.2