On Mon, Aug 18, 2025 at 9:25 PM Tamar Christina <tamar.christ...@arm.com> wrote:
> commit g:fb59c5719c17a04ecfd58b5e566eccd6d2ac583a stops passing the scalar > type > (confusingly named vectype) to the costing hook when doing scalar costing. > > As a result, we could no longer distinguish between FPR and GPR scalar > stmts. > A later commit also removed STMT_VINFO_VECTYPE from stmt_info. > > This leaves the only remaining option to get the type of the original stmt > in > the stmt_info. This patch does this when we're performing scalar costing. > > Ideally I'd refactor this a bit because a lot of the hooks just need to > know if > it's FP or not, but this seems pointless with the ongoing costing churn. > So for > now this restores our costing. > > Bootstrapped Regtested on aarch64-none-linux-gnu, > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > -m32, -m64 and no issues. > > Ok for master? > Ok. > > Thanks, > Tamar > > gcc/ChangeLog: > > PR target/121536 > * config/aarch64/aarch64.cc (aarch64_vector_costs::add_stmt_cost): > Set > vectype from type of lhs of gimple stmt. > > --- > diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc > index > f88b7c95f97e7099af00112405279afd05e045fd..2971224566f14da4a163a7d0aed72bdbb3ac40f9 > 100644 > --- a/gcc/config/aarch64/aarch64.cc > +++ b/gcc/config/aarch64/aarch64.cc > @@ -18045,6 +18045,17 @@ aarch64_vector_costs::add_stmt_cost (int count, > vect_cost_for_stmt kind, > tree vectype, int misalign, > vect_cost_model_location where) > { > + /* If costing for scalar vectype will be null, look up the type > through + stmt_info. */ > Though I think this comment should be reworded slightly: When costing for scalars, vectype will be NULL; so look up the type via stmt_info's statement. Thanks, Andrew Pinski > + if (m_costing_for_scalar && stmt_info) > + { > + gcc_assert (!vectype); > + /* This won't work for e.g. gconds or other statements without a > lhs, > + but those only work on GPR anyway and this is the best we can > do. */ > + if (tree lhs = gimple_get_lhs (STMT_VINFO_STMT (stmt_info))) > + vectype = TREE_TYPE (lhs); > + } > + > fractional_cost stmt_cost > = aarch64_builtin_vectorization_cost (kind, vectype, misalign); > > > > -- >