[PATCH 12/13] use convert_to_jump() when converting a CBR with same targets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If a conditional branch has identical targets, it should be
converted to a simple jump.

This is done but using its own code.
Change this by using the existing convert_to_jump() instead.
This also allows any redundant phi-sources to be removed.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 simplify.c                     | 13 ++-----------
 validation/optim/bad-phisrc2.c |  1 -
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/simplify.c b/simplify.c
index 7171bd564e63..90db041af823 100644
--- a/simplify.c
+++ b/simplify.c
@@ -2444,17 +2444,8 @@ static int simplify_branch(struct instruction *insn)
 		return convert_to_jump(insn, cond->value ? insn->bb_true : insn->bb_false);
 
 	/* Same target? */
-	if (insn->bb_true == insn->bb_false) {
-		struct basic_block *bb = insn->bb;
-		struct basic_block *target = insn->bb_false;
-		remove_bb_from_list(&target->parents, bb, 1);
-		remove_bb_from_list(&bb->children, target, 1);
-		insn->bb_false = NULL;
-		kill_use(&insn->cond);
-		insn->cond = NULL;
-		insn->opcode = OP_BR;
-		return REPEAT_CSE|REPEAT_CFG_CLEANUP;
-	}
+	if (insn->bb_true == insn->bb_false)
+		return convert_to_jump(insn, insn->bb_true);
 
 	/* Conditional on a SETNE $0 or SETEQ $0 */
 	if (cond->type == PSEUDO_REG) {
diff --git a/validation/optim/bad-phisrc2.c b/validation/optim/bad-phisrc2.c
index 3eade688f768..78eae28856fd 100644
--- a/validation/optim/bad-phisrc2.c
+++ b/validation/optim/bad-phisrc2.c
@@ -10,7 +10,6 @@ int bad_phisrc2(int p, int a, int r)
 /*
  * check-name: bad-phisrc2
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-contains: select\\.
-- 
2.31.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux