From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1971) id 490A038582B0; Thu, 19 Oct 2023 17:31:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 490A038582B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697736662; bh=WhXghF2XPZ6cwh2e/gVtarT4WfZpLlTOuS2C62Und9o=; h=From:To:Subject:Date:From; b=IKeWPDoS7zYdP9xN+0YlFnIm1XCNxKnoO/veWCmsdO7ifLVE7zn7E1ujrROJKW8Xc JHND+ZLfI3H8Ynm/Q/QnG6EQkh1+6JT5dRGeYlFjQeA/iR73sZNXQUGWXgHcUIdeRz V3wkbvgEZjYFzfL7lAL8bhjMwrcS6+uUv4IO8JDQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andre Simoes Dias Vieira To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-4765] vect: don't allow fully masked loops with non-masked simd clones [PR 110485] X-Act-Checkin: gcc X-Git-Author: Andre Vieira X-Git-Refname: refs/heads/master X-Git-Oldrev: c9ce846763c3d220c754ac0a327e275ac00a83e1 X-Git-Newrev: 8b704ed0b8f35ec1a57e70bd8e6913ba0e9d1f24 Message-Id: <20231019173102.490A038582B0@sourceware.org> Date: Thu, 19 Oct 2023 17:31:01 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8b704ed0b8f35ec1a57e70bd8e6913ba0e9d1f24 commit r14-4765-g8b704ed0b8f35ec1a57e70bd8e6913ba0e9d1f24 Author: Andre Vieira Date: Thu Oct 19 18:28:12 2023 +0100 vect: don't allow fully masked loops with non-masked simd clones [PR 110485] When analyzing a loop and choosing a simdclone to use it is possible to choose a simdclone that cannot be used 'inbranch' for a loop that can use partial vectors. This may lead to the vectorizer deciding to use partial vectors which are not supported for notinbranch simd clones. This patch fixes that by disabling the use of partial vectors once a notinbranch simd clone has been selected. gcc/ChangeLog: PR tree-optimization/110485 * tree-vect-stmts.cc (vectorizable_simd_clone_call): Disable partial vectors usage if a notinbranch simdclone has been selected. gcc/testsuite/ChangeLog: * gcc.dg/gomp/pr110485.c: New test. Diff: --- gcc/testsuite/gcc.dg/gomp/pr110485.c | 19 +++++++++++++++++++ gcc/tree-vect-stmts.cc | 11 +++++++++++ 2 files changed, 30 insertions(+) diff --git a/gcc/testsuite/gcc.dg/gomp/pr110485.c b/gcc/testsuite/gcc.dg/gomp/pr110485.c new file mode 100644 index 000000000000..ba6817a127f4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr110485.c @@ -0,0 +1,19 @@ +/* PR 110485 */ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast -fdump-tree-vect-details" } */ +/* { dg-additional-options "-march=znver4 --param=vect-partial-vector-usage=1" { target x86_64-*-* } } */ +#pragma omp declare simd notinbranch uniform(p) +extern double __attribute__ ((const)) bar (double a, double p); + +double a[1024]; +double b[1024]; + +void foo (int n) +{ + #pragma omp simd + for (int i = 0; i < n; ++i) + a[i] = bar (b[i], 71.2); +} + +/* { dg-final { scan-tree-dump-not "MASK_LOAD" "vect" } } */ +/* { dg-final { scan-tree-dump "can't use a fully-masked loop because a non-masked simd clone was selected." "vect" { target x86_64-*-* } } } */ diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 8abb5f17f7f1..e96ff2c8e7cc 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -4377,6 +4377,17 @@ vectorizable_simd_clone_call (vec_info *vinfo, stmt_vec_info stmt_info, ? boolean_true_node : boolean_false_node; simd_clone_info.safe_push (sll); } + + if (!bestn->simdclone->inbranch && loop_vinfo) + { + if (dump_enabled_p () + && LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo)) + dump_printf_loc (MSG_NOTE, vect_location, + "can't use a fully-masked loop because a" + " non-masked simd clone was selected.\n"); + LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) = false; + } + STMT_VINFO_TYPE (stmt_info) = call_simd_clone_vec_info_type; DUMP_VECT_SCOPE ("vectorizable_simd_clone_call"); /* vect_model_simple_cost (vinfo, stmt_info, ncopies,