diff mbox

[7/8] check duplicated phi-nodes directly on dominators

Message ID 20170413165551.2785-8-luc.vanoostenryck@gmail.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Luc Van Oostenryck April 13, 2017, 4:55 p.m. UTC
Now that add_load_dominators() is integrated into
rewrite_load_instruction() we can check for duplicated
phi sources directly in the dominators list instead
to have to check the corresponding phi sources.

This is a preparatory step for the next patch where
unneeded phi sources are not created anymore.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 flow.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/flow.c b/flow.c
index b64a3f74a..d705abe2e 100644
--- a/flow.c
+++ b/flow.c
@@ -439,6 +439,7 @@  void rewrite_load_instruction(struct instruction *insn, struct instruction_list
 	struct ident *ident)
 {
 	struct pseudo_list *dominators;
+	struct instruction *dom;
 	pseudo_t new, phi;
 
 	dominators = add_load_dominators(insn, doms, ident);
@@ -447,12 +448,12 @@  void rewrite_load_instruction(struct instruction *insn, struct instruction_list
 	 * Check for somewhat common case of duplicate
 	 * phi nodes.
 	 */
-	new = first_pseudo(dominators)->def->src1;
-	FOR_EACH_PTR(dominators, phi) {
-		if (new != phi->def->src1)
+	new = first_instruction(doms)->target;
+	FOR_EACH_PTR(doms, dom) {
+		if (new != dom->target)
 			goto complex_phi;
-		new->ident = new->ident ? : phi->ident;
-	} END_FOR_EACH_PTR(phi);
+		new->ident = new->ident ? : ident ? : dom->target->ident;
+	} END_FOR_EACH_PTR(dom);
 
 	/*
 	 * All the same pseudo - mark the phi-nodes unused