From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2063) id 3B1593858C2F; Thu, 27 Jul 2023 02:43:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B1593858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690425837; bh=Ay8vlK1AddlaXEs7AvtWesfqZgQKTvh70wbRYJCBr7k=; h=From:To:Subject:Date:From; b=myy7FnEWwTdpEaBEgwVVhtxniHFQ83EmRs/uoOBpoLY9sGRzJClGC/AhsRtvhTfpy QQeRmYKDpAomGV4ygiaubThhoxMp168bsq/GOggK2WTuiB5cZ+Mf/+oJH41fyE0HcC TQHf5E1X0WhM1zZ58E0gKP06GPnrZXQShKRwnJ+I= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Kewen Lin To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-2813] vect: Treat VMAT_ELEMENTWISE as scalar load in costing [PR110776] X-Act-Checkin: gcc X-Git-Author: Kewen Lin X-Git-Refname: refs/heads/master X-Git-Oldrev: 6f709f79c915a1ea82220a44e9f4a144d5eedfd1 X-Git-Newrev: 9890d4e8bcda1f34b8eefb481935ef0e4cd8069e Message-Id: <20230727024357.3B1593858C2F@sourceware.org> Date: Thu, 27 Jul 2023 02:43:57 +0000 (GMT) List-Id: https://gcc.gnu.org/g:9890d4e8bcda1f34b8eefb481935ef0e4cd8069e commit r14-2813-g9890d4e8bcda1f34b8eefb481935ef0e4cd8069e Author: Kewen Lin Date: Wed Jul 26 21:43:09 2023 -0500 vect: Treat VMAT_ELEMENTWISE as scalar load in costing [PR110776] PR110776 exposes one issue that we could query unaligned load for vector type but actually no unaligned vector load is supported there. The reason is that the costed load is with single-lane vector type and its memory access type is VMAT_ELEMENTWISE, we actually take it as scalar load and set its alignment_support_scheme as dr_unaligned_supported. To avoid the ICE as exposed, following Rich's suggestion, this patch is to make VMAT_ELEMENTWISE be costed as scalar load. Co-authored-by: Richard Biener PR tree-optimization/110776 gcc/ChangeLog: * tree-vect-stmts.cc (vectorizable_load): Always cost VMAT_ELEMENTWISE as scalar load. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr110776.c: New test. Diff: --- gcc/testsuite/gcc.target/powerpc/pr110776.c | 22 ++++++++++++++++++++++ gcc/tree-vect-stmts.cc | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.target/powerpc/pr110776.c b/gcc/testsuite/gcc.target/powerpc/pr110776.c new file mode 100644 index 00000000000..749159fd675 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr110776.c @@ -0,0 +1,22 @@ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=power6 -maltivec" } */ + +/* Verify there is no ICE. */ + +int a; +long *b; +int +c () +{ + long e; + int d = 0; + for (long f; f; f++) + { + e = b[f * a]; + if (e) + d = 1; + } + if (d) + for (;;) + ; +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 5018bd23e6e..6a4e8fce126 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -9876,7 +9876,10 @@ vectorizable_load (vec_info *vinfo, { if (costing_p) { - if (VECTOR_TYPE_P (ltype)) + /* For VMAT_ELEMENTWISE, just cost it as scalar_load to + avoid ICE, see PR110776. */ + if (VECTOR_TYPE_P (ltype) + && memory_access_type != VMAT_ELEMENTWISE) vect_get_load_cost (vinfo, stmt_info, 1, alignment_support_scheme, misalignment, false, &inside_cost, nullptr, cost_vec,