Message ID | CACUk7=VuFVVKmEKv=ZmOnNCa34sW2YWqYFe0Jw4zSLi3rCak9w@mail.gmail.com |
---|---|
State | Accepted |
Headers | show |
On Thu, Jun 14, 2012 at 1:26 PM, Ramana Radhakrishnan <ramana.radhakrishnan@linaro.org> wrote: > Hi, > > This patch allows propagation of vector constants into VEC_PERM_EXPRs > in lower_vec_perm, motivation explained in > http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00615.html > > Bootstrapped and regression tested on gcc110.fsffrance.org . > > Ok ? Ok. Thanks, Richard. > regards, > Ramana > > * tree-vect-generic.c (lower_vec_perm): Propagate vector constants > into VEC_PERM_EXPR.. > > diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c > index 06334bb..3b9f561 100644 > --- a/gcc/tree-vect-generic.c > +++ b/gcc/tree-vect-generic.c > @@ -628,6 +628,14 @@ lower_vec_perm (gimple_stmt_iterator *gsi) > location_t loc = gimple_location (gsi_stmt (*gsi)); > unsigned i; > > + if (TREE_CODE (mask) == SSA_NAME) > + { > + gimple def_stmt = SSA_NAME_DEF_STMT (mask); > + if (is_gimple_assign (def_stmt) > + && gimple_assign_rhs_code (def_stmt) == VECTOR_CST) > + mask = gimple_assign_rhs1 (def_stmt); > + } > + > if (TREE_CODE (mask) == VECTOR_CST) > { > unsigned char *sel_int = XALLOCAVEC (unsigned char, elements); > @@ -637,7 +645,11 @@ lower_vec_perm (gimple_stmt_iterator *gsi) > & (2 * elements - 1)); > > if (can_vec_perm_p (TYPE_MODE (vect_type), false, sel_int)) > - return; > + { > + gimple_assign_set_rhs3 (stmt, mask); > + update_stmt (stmt); > + return; > + } > } > else if (can_vec_perm_p (TYPE_MODE (vect_type), true, NULL)) > return;
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c index 06334bb..3b9f561 100644 --- a/gcc/tree-vect-generic.c +++ b/gcc/tree-vect-generic.c @@ -628,6 +628,14 @@ lower_vec_perm (gimple_stmt_iterator *gsi) location_t loc = gimple_location (gsi_stmt (*gsi)); unsigned i; + if (TREE_CODE (mask) == SSA_NAME) + { + gimple def_stmt = SSA_NAME_DEF_STMT (mask); + if (is_gimple_assign (def_stmt) + && gimple_assign_rhs_code (def_stmt) == VECTOR_CST) + mask = gimple_assign_rhs1 (def_stmt); + } + if (TREE_CODE (mask) == VECTOR_CST) { unsigned char *sel_int = XALLOCAVEC (unsigned char, elements); @@ -637,7 +645,11 @@ lower_vec_perm (gimple_stmt_iterator *gsi) & (2 * elements - 1)); if (can_vec_perm_p (TYPE_MODE (vect_type), false, sel_int)) - return; + { + gimple_assign_set_rhs3 (stmt, mask); + update_stmt (stmt); + return; + } } else if (can_vec_perm_p (TYPE_MODE (vect_type), true, NULL)) return;