From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2063) id BA9AE3858C74; Thu, 27 Jan 2022 11:16:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA9AE3858C74 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 r12-6891] rs6000: Fix an assertion in update_target_cost_per_stmt [PR103702] X-Act-Checkin: gcc X-Git-Author: Kewen Lin X-Git-Refname: refs/heads/master X-Git-Oldrev: 1c91b014923f418e0aab789c5cf57facf04bf266 X-Git-Newrev: 2022be54daf638885e1e685afd36619cb4b01a93 Message-Id: <20220127111643.BA9AE3858C74@sourceware.org> Date: Thu, 27 Jan 2022 11:16:43 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Jan 2022 11:16:43 -0000 https://gcc.gnu.org/g:2022be54daf638885e1e685afd36619cb4b01a93 commit r12-6891-g2022be54daf638885e1e685afd36619cb4b01a93 Author: Kewen Lin Date: Thu Jan 27 03:46:28 2022 -0600 rs6000: Fix an assertion in update_target_cost_per_stmt [PR103702] This patch is to fix one wrong assertion which is too aggressive. Vectorizer can do vec_construct costing for the vector type which only has one unit. For the failed case, the passed in vector type is "vector(1) int", though it doesn't end up with any construction eventually, we have to handle this kind of possibility. gcc/ChangeLog: PR target/103702 * config/rs6000/rs6000.cc (rs6000_cost_data::update_target_cost_per_stmt): Fix one wrong assertion with early return. gcc/testsuite/ChangeLog: PR target/103702 * gcc.target/powerpc/pr103702.c: New test. Diff: --- gcc/config/rs6000/rs6000.cc | 7 +++++-- gcc/testsuite/gcc.target/powerpc/pr103702.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index e5471da4504..a5fd36b72d9 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -5439,8 +5439,11 @@ rs6000_cost_data::update_target_cost_per_stmt (vect_cost_for_stmt kind, { tree vectype = STMT_VINFO_VECTYPE (stmt_info); unsigned int nunits = vect_nunits_for_cost (vectype); - /* We don't expect strided/elementwise loads for just 1 nunit. */ - gcc_assert (nunits > 1); + /* As PR103702 shows, it's possible that vectorizer wants to do + costings for only one unit here, it's no need to do any + penalization for it, so simply early return here. */ + if (nunits == 1) + return; /* i386 port adopts nunits * stmt_cost as the penalized cost for this kind of penalization, we used to follow it but found it could result in an unreliable body cost especially diff --git a/gcc/testsuite/gcc.target/powerpc/pr103702.c b/gcc/testsuite/gcc.target/powerpc/pr103702.c new file mode 100644 index 00000000000..585946fd64b --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr103702.c @@ -0,0 +1,24 @@ +/* We don't have one powerpc.*_ok for Power6, use altivec_ok conservatively. */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-mdejagnu-cpu=power6 -O2 -ftree-loop-vectorize -fno-tree-scev-cprop" } */ + +/* Verify there is no ICE. */ + +unsigned short a, e; +int *b, *d; +int c; +extern int fn2 (); +void +fn1 () +{ + void *f; + for (;;) + { + fn2 (); + b = f; + e = 0; + for (; e < a; ++e) + b[e] = d[e * c]; + } +} +