On Thu, Sep 13, 2012 at 8:05 PM, Marc Glisse <marc.gli...@inria.fr> wrote: > Hello, > > this patch is a minor cleanup of my previous forwprop patches for vectors. I > have known about get_prop_source_stmt from the beginning, but for some > reason I always used SSA_NAME_DEF_STMT. This makes the source code slightly > shorter, and together with PR 54565 it should help get some optimizations to > apply as early as forwprop1 instead of forwprop2. > > There is one line I had badly indented. I am not sure what the policy is for > that. Silently bundling it with this patch as I am doing is probably not so > good. I should probably just fix it in svn without asking the list, but I > was wondering if I should add a ChangeLog entry and post the committed patch > to the list afterwards? (that's what I would do by default, at worst it is a > bit of spam)
That's ok, no changelog needed for that. Ok. Thanks, Richard. > passes bootstrap+testsuite > > 2012-09-14 Marc Glisse <marc.gli...@inria.fr> > > * tree-ssa-forwprop.c (simplify_bitfield_ref): Call > get_prop_source_stmt. > (simplify_permutation): Likewise. > (simplify_vector_constructor): Likewise. > > -- > Marc Glisse > Index: tree-ssa-forwprop.c > =================================================================== > --- tree-ssa-forwprop.c (revision 191247) > +++ tree-ssa-forwprop.c (working copy) > @@ -2599,23 +2599,22 @@ simplify_bitfield_ref (gimple_stmt_itera > elem_type = TREE_TYPE (TREE_TYPE (op0)); > if (TREE_TYPE (op) != elem_type) > return false; > > size = TREE_INT_CST_LOW (TYPE_SIZE (elem_type)); > op1 = TREE_OPERAND (op, 1); > n = TREE_INT_CST_LOW (op1) / size; > if (n != 1) > return false; > > - def_stmt = SSA_NAME_DEF_STMT (op0); > - if (!def_stmt || !is_gimple_assign (def_stmt) > - || !can_propagate_from (def_stmt)) > + def_stmt = get_prop_source_stmt (op0, false, NULL); > + if (!def_stmt || !can_propagate_from (def_stmt)) > return false; > > op2 = TREE_OPERAND (op, 2); > idx = TREE_INT_CST_LOW (op2) / size; > > code = gimple_assign_rhs_code (def_stmt); > > if (code == VEC_PERM_EXPR) > { > tree p, m, index, tem; > @@ -2630,21 +2629,21 @@ simplify_bitfield_ref (gimple_stmt_itera > { > p = gimple_assign_rhs1 (def_stmt); > } > else > { > p = gimple_assign_rhs2 (def_stmt); > idx -= nelts; > } > index = build_int_cst (TREE_TYPE (TREE_TYPE (m)), idx * size); > tem = build3 (BIT_FIELD_REF, TREE_TYPE (op), > - unshare_expr (p), op1, index); > + unshare_expr (p), op1, index); > gimple_assign_set_rhs1 (stmt, tem); > fold_stmt (gsi); > update_stmt (gsi_stmt (*gsi)); > return true; > } > > return false; > } > > /* Determine whether applying the 2 permutations (mask1 then mask2) > @@ -2682,40 +2681,40 @@ is_combined_permutation_identity (tree m > /* Combine a shuffle with its arguments. Returns 1 if there were any > changes made, 2 if cfg-cleanup needs to run. Else it returns 0. */ > > static int > simplify_permutation (gimple_stmt_iterator *gsi) > { > gimple stmt = gsi_stmt (*gsi); > gimple def_stmt; > tree op0, op1, op2, op3, arg0, arg1; > enum tree_code code; > + bool single_use_op0 = false; > > gcc_checking_assert (gimple_assign_rhs_code (stmt) == VEC_PERM_EXPR); > > op0 = gimple_assign_rhs1 (stmt); > op1 = gimple_assign_rhs2 (stmt); > op2 = gimple_assign_rhs3 (stmt); > > if (TREE_CODE (op2) != VECTOR_CST) > return 0; > > if (TREE_CODE (op0) == VECTOR_CST) > { > code = VECTOR_CST; > arg0 = op0; > } > else if (TREE_CODE (op0) == SSA_NAME) > { > - def_stmt = SSA_NAME_DEF_STMT (op0); > - if (!def_stmt || !is_gimple_assign (def_stmt) > - || !can_propagate_from (def_stmt)) > + def_stmt = get_prop_source_stmt (op0, false, &single_use_op0); > + if (!def_stmt || !can_propagate_from (def_stmt)) > return 0; > > code = gimple_assign_rhs_code (def_stmt); > arg0 = gimple_assign_rhs1 (def_stmt); > } > else > return 0; > > /* Two consecutive shuffles. */ > if (code == VEC_PERM_EXPR) > @@ -2740,35 +2739,31 @@ simplify_permutation (gimple_stmt_iterat > return remove_prop_source_from_use (op0) ? 2 : 1; > } > > /* Shuffle of a constructor. */ > else if (code == CONSTRUCTOR || code == VECTOR_CST) > { > tree opt; > bool ret = false; > if (op0 != op1) > { > - if (TREE_CODE (op0) == SSA_NAME && !has_single_use (op0)) > + if (TREE_CODE (op0) == SSA_NAME && !single_use_op0) > return 0; > > if (TREE_CODE (op1) == VECTOR_CST) > arg1 = op1; > else if (TREE_CODE (op1) == SSA_NAME) > { > enum tree_code code2; > > - if (!has_single_use (op1)) > - return 0; > - > - gimple def_stmt2 = SSA_NAME_DEF_STMT (op1); > - if (!def_stmt2 || !is_gimple_assign (def_stmt2) > - || !can_propagate_from (def_stmt2)) > + gimple def_stmt2 = get_prop_source_stmt (op1, true, NULL); > + if (!def_stmt2 || !can_propagate_from (def_stmt2)) > return 0; > > code2 = gimple_assign_rhs_code (def_stmt2); > if (code2 != CONSTRUCTOR && code2 != VECTOR_CST) > return 0; > arg1 = gimple_assign_rhs1 (def_stmt2); > } > else > return 0; > } > @@ -2824,22 +2819,22 @@ simplify_vector_constructor (gimple_stmt > maybe_ident = true; > FOR_EACH_VEC_ELT (constructor_elt, CONSTRUCTOR_ELTS (op), i, elt) > { > tree ref, op1; > > if (i >= nelts) > return false; > > if (TREE_CODE (elt->value) != SSA_NAME) > return false; > - def_stmt = SSA_NAME_DEF_STMT (elt->value); > - if (!def_stmt || !is_gimple_assign (def_stmt)) > + def_stmt = get_prop_source_stmt (elt->value, false, NULL); > + if (!def_stmt) > return false; > code = gimple_assign_rhs_code (def_stmt); > if (code != BIT_FIELD_REF) > return false; > op1 = gimple_assign_rhs1 (def_stmt); > ref = TREE_OPERAND (op1, 0); > if (orig) > { > if (ref != orig) > return false; >