From patchwork Wed Dec 20 15:17:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andre Vieira (lists)" X-Patchwork-Id: 1878572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SwHHC3ttBz20Gb for ; Thu, 21 Dec 2023 02:17:26 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 13741385E017 for ; Wed, 20 Dec 2023 15:17:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id CB3233858D20 for ; Wed, 20 Dec 2023 15:17:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB3233858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CB3233858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703085434; cv=none; b=hKU1xdOCQoh5GzFWg8cyeXp21I69qK2wzfctIfPGu0X7G34niljFSoxyKsYQzlPYQl9R+xNZPesgFlrkE5K1Fxh+uAOrZvg8ap5kbz8CogpGbzlxCnIzFEdZESBuakfv0SlZljKK6Oj1EXOuut+evHfjowM7BRA0D69ftPJH8n0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703085434; c=relaxed/simple; bh=hc027gMDfT1NcsEenri+smcwmdFiNEXurZEIU67zI3U=; h=Message-ID:Date:MIME-Version:To:From:Subject; b=PmLsgYtTWRvsOotiyFVHLxLUALZwBSdR21WL8eh1Es5tDM3rtTSI9G0u7s01gEg6JJkL9T7paFItJ29DQdYD5wZZqrYWL8QT79tOfhrlIaIWakVa9aFIklg2d7iwNgpmwV0udcGCmLEHe3FCHDdr2wAEYIaz8GxhYuMr3WaV6+k= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 43D891FB; Wed, 20 Dec 2023 07:17:57 -0800 (PST) Received: from [10.57.74.123] (unknown [10.57.74.123]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B42533F64C; Wed, 20 Dec 2023 07:17:11 -0800 (PST) Message-ID: Date: Wed, 20 Dec 2023 15:17:09 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "gcc-patches@gcc.gnu.org" Cc: Richard Biener , hjl.tools@gmail.com, "jakub@redhat.com" From: "Andre Vieira (lists)" Subject: omp: Fix simdclone arguments with veclen lower than simdlen [PR113040] X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org This patch fixes an issue introduced by: commit ea4a3d08f11a59319df7b750a955ac613a3f438a Author: Andre Vieira Date: Wed Nov 1 17:02:41 2023 +0000 omp: Reorder call for TARGET_SIMD_CLONE_ADJUST The problem was that after this patch we no longer added multiple arguments for vector arguments where the veclen was lower than the simdlen. gcc/ChangeLog: * omp-simd-clone.cc (simd_clone_adjust_argument_types): Add multiple vector arguments where simdlen is larger than veclen. Bootstrapped and regression tested on x86_64-pc-linux-gnu and aarch64-unknown-linux-gnu. OK for trunk? PS: struggling to add a testcase for this, the dumps don't show the simdclone prototype and I can't easily create a run-test for this as it requires glibc. Only option is a very flaky assembly scan test to see if it's writing to ymm4 (i.e. it is passing enough parameters), but I haven't because I don't think that's a good idea. PPS: maybe we ought to print the simdclone prototype when passing -fdump-ipa-simdclone ? diff --git a/gcc/omp-simd-clone.cc b/gcc/omp-simd-clone.cc index 3fbe428125243bc02bd58f6e50a3333c773e8df8..5151fef3bcdaa76802184df43ba13b8709645fd4 100644 --- a/gcc/omp-simd-clone.cc +++ b/gcc/omp-simd-clone.cc @@ -781,6 +781,7 @@ simd_clone_adjust_argument_types (struct cgraph_node *node) struct cgraph_simd_clone *sc = node->simdclone; unsigned i, k; poly_uint64 veclen; + auto_vec new_params; for (i = 0; i < sc->nargs; ++i) { @@ -798,9 +799,11 @@ simd_clone_adjust_argument_types (struct cgraph_node *node) switch (sc->args[i].arg_type) { default: + new_params.safe_push (parm_type); break; case SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP: case SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_VARIABLE_STEP: + new_params.safe_push (parm_type); if (node->definition) sc->args[i].simd_array = create_tmp_simd_array (IDENTIFIER_POINTER (DECL_NAME (parm)), @@ -828,6 +831,9 @@ simd_clone_adjust_argument_types (struct cgraph_node *node) else vtype = build_vector_type (parm_type, veclen); sc->args[i].vector_type = vtype; + k = vector_unroll_factor (sc->simdlen, veclen); + for (unsigned j = 0; j < k; j++) + new_params.safe_push (vtype); if (node->definition) sc->args[i].simd_array @@ -893,22 +899,8 @@ simd_clone_adjust_argument_types (struct cgraph_node *node) last_parm_void = true; gcc_assert (TYPE_ARG_TYPES (TREE_TYPE (node->decl))); - for (i = 0; i < sc->nargs; i++) - { - tree ptype; - switch (sc->args[i].arg_type) - { - default: - ptype = sc->args[i].orig_type; - break; - case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP: - case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP: - case SIMD_CLONE_ARG_TYPE_VECTOR: - ptype = sc->args[i].vector_type; - break; - } - new_arg_types = tree_cons (NULL_TREE, ptype, new_arg_types); - } + for (i = 0; i < new_params.length (); i++) + new_arg_types = tree_cons (NULL_TREE, new_params[i], new_arg_types); new_reversed = nreverse (new_arg_types); if (last_parm_void) {