This series, after some related and preparatory patches, contains fixes for the problem of phi-sources being left in place after their corresponding branches have been removed. This results in situations, for example, where a phi-node has 3 arguments/inputs/sources but only 2 parent BBs and create all sort of problems, like: * some dead code is not removed * some optimizations involving phi-nodes are blocked (if-conversions) * more importantly, these phi-nodes are invalid/meaningless and so it's impossible to reason correctly about them. Note: This series only fixes *some* of these problems. Other probably still exists, especially when rewrite_branch() is used. Luc Van Oostenryck (13): Revert "simplify CBR-CBR on the same condition" add testcases to check if phi-sources from removed targets are removed too remove insert_branch() redundant arg simplify remove_parent() fold remove_parent() into insert_branch() let insert_branch() reuse the terminating instruction move insert_branch() to flow.c let insert_branch() return a status rename insert_branch() to convert_to_jump() add remove_phisources() fix phisources during CBR-BR conversion use convert_to_jump() when converting a CBR with same targets fix phisources during SWITCH-BR conversion flow.c | 205 +++++++++++++++----------------- flow.h | 3 + linearize.c | 36 ------ linearize.h | 1 - simplify.c | 34 ++---- validation/optim/bad-phisrc1.c | 15 +++ validation/optim/bad-phisrc1a.c | 23 ++++ validation/optim/bad-phisrc2.c | 16 +++ validation/optim/bad-phisrc3.c | 20 ++++ 9 files changed, 184 insertions(+), 169 deletions(-) create mode 100644 validation/optim/bad-phisrc1.c create mode 100644 validation/optim/bad-phisrc1a.c create mode 100644 validation/optim/bad-phisrc2.c create mode 100644 validation/optim/bad-phisrc3.c -- 2.31.0