diff mbox series

[11/13] fix phisources during CBR-BR conversion

Message ID 20210321123505.27993-12-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series remove phi-sources from removed branches | expand

Commit Message

Luc Van Oostenryck March 21, 2021, 12:35 p.m. UTC
When a parent is removed from a BB containing one or several phi-nodes,
the corresponding phi-sources must be removed from the phi-node.

However this is not done and consequentially:
* it becomes impossibly to correctly reason about the flow of values
  through these phi-nodes.
* simplifications are missed (e.g. if-conversion).

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 flow.c                          | 5 +++++
 validation/optim/bad-phisrc1.c  | 1 -
 validation/optim/bad-phisrc1a.c | 1 -
 3 files changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/flow.c b/flow.c
index 4952562a373d..69d95a98a512 100644
--- a/flow.c
+++ b/flow.c
@@ -760,6 +760,11 @@  int convert_to_jump(struct instruction *insn, struct basic_block *target)
 	struct basic_block *child;
 	int changed = REPEAT_CSE;
 
+	switch (insn->opcode) {
+	case OP_CBR:
+		changed |= remove_phisources(insn->bb, insn->bb_true == target ? insn->bb_false : insn->bb_true);
+		break;
+	}
 	kill_use(&insn->cond);
 	insn->bb_true = target;
 	insn->bb_false = NULL;
diff --git a/validation/optim/bad-phisrc1.c b/validation/optim/bad-phisrc1.c
index 59c5e4f1e66a..aa12dd0ae542 100644
--- a/validation/optim/bad-phisrc1.c
+++ b/validation/optim/bad-phisrc1.c
@@ -8,7 +8,6 @@  void foo(int a, int b)
 /*
  * check-name: bad-phisrc1
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-excludes: phi\\.
diff --git a/validation/optim/bad-phisrc1a.c b/validation/optim/bad-phisrc1a.c
index cf07573b1fd3..b7519ee7cf5d 100644
--- a/validation/optim/bad-phisrc1a.c
+++ b/validation/optim/bad-phisrc1a.c
@@ -16,7 +16,6 @@  out:
 /*
  * check-name: bad-phisrc1a
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-contains: select\\.