--- mem2reg.c | 71 ++++++++++++++++++++++++----------------- validation/loop-linearization.c | 4 +-- 2 files changed, 43 insertions(+), 32 deletions(-) diff --git a/mem2reg.c b/mem2reg.c index e27739701..5f1c968a0 100644 --- a/mem2reg.c +++ b/mem2reg.c @@ -70,6 +70,10 @@ complex_phi: return new; } + +static pseudo_t find_dominating_value(struct symbol *sym, struct instruction *insn, + struct basic_block *bb, unsigned long generation, int local); + /* * sym - the symbol/var we're looking the value for * insn - a load of 'sym' @@ -110,13 +114,9 @@ static int find_dominating_parents(struct symbol *sym, struct instruction *insn, goto found_dominator; } END_FOR_EACH_PTR_REVERSE(one); no_dominance: - if (parent->generation == generation) - continue; - parent->generation = generation; - - if (!find_dominating_parents(sym, insn, parent, generation, dominators, local)) + dom = find_dominating_value(sym, insn, parent, generation, local); + if (!dom) return 0; - continue; found_dominator: add_pseudo(dominators, dom); @@ -124,6 +124,39 @@ found_dominator: return 1; } +static pseudo_t find_dominating_value(struct symbol *sym, struct instruction *insn, + struct basic_block *bb, unsigned long generation, int local) +{ + struct pseudo_list *dominators = NULL; + + if (bb->generation == generation) { + return insn->target; + // FIXME: is that exact ? + } + + bb->generation = generation; + if (!find_dominating_parents(sym, insn, bb, generation, &dominators, local)) + return NULL; + + /* This happens with initial assignments to structures etc.. */ + if (!dominators) { + if (!local) + return NULL; + check_access(insn); + + // FIXME: should be UNDEF + return value_pseudo(0); + } + + /* + * If we find just one dominating instruction, we + * can turn it into a direct thing. Otherwise we'll + * have to turn the load into a phi-node of the + * dominators. + */ + return dominating_value(sym, bb, dominators); +} + /* * sym: a symbol/variable * insn: is a load of the symbol 'sym'. @@ -134,7 +167,6 @@ static int find_dominating_stores(struct symbol *sym, struct instruction *insn, { struct basic_block *bb = insn->bb; struct instruction *one, *dom = NULL; - struct pseudo_list *dominators; pseudo_t pseudo = sym->pseudo; pseudo_t val; int partial; @@ -177,31 +209,10 @@ found: } /* OK, go find the parents */ - bb->generation = generation; - - dominators = NULL; - if (!find_dominating_parents(sym, insn, bb, generation, &dominators, local)) + val = find_dominating_value(sym, insn, bb, generation, local); + if (!val) return 0; - /* This happens with initial assignments to structures etc.. */ - if (!dominators) { - if (!local) - return 0; - check_access(insn); - - // FIXME: should be UNDEF - val = value_pseudo(0); - goto convert; - } - - /* - * If we find just one dominating instruction, we - * can turn it into a direct thing. Otherwise we'll - * have to turn the load into a phi-node of the - * dominators. - */ - val = dominating_value(sym, bb, dominators); - convert: convert_load_instruction(insn, val); return 1; diff --git a/validation/loop-linearization.c b/validation/loop-linearization.c index 6c531d056..9b35cf699 100644 --- a/validation/loop-linearization.c +++ b/validation/loop-linearization.c @@ -89,8 +89,8 @@ fwhile: br .L15 .L14: - add.32 %r15 <- %r16, $1 - phisrc.32 %phi8 <- %r15 + add.32 %r15(i) <- %r16, $1 + phisrc.32 %phi8 <- %r15(i) br .L12 .L11: -- 2.14.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html