From patchwork Fri Aug 5 12:56:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andre Vieira (lists)" X-Patchwork-Id: 402 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:20da:b0:2d3:3019:e567 with SMTP id n26csp175952pxc; Fri, 5 Aug 2022 05:57:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR6/eOlECqoxzn7Uo21DhDwDHf+lzJccbuKbN2dBczNUGx8pGsf/43QvRM8jEJLH/xypUfXT X-Received: by 2002:aa7:d60b:0:b0:43c:f7ab:3c8f with SMTP id c11-20020aa7d60b000000b0043cf7ab3c8fmr6567268edr.6.1659704262075; Fri, 05 Aug 2022 05:57:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659704262; cv=none; d=google.com; s=arc-20160816; b=fE9+xwrHpodAjIEyrUlnjmzts1VJYbeirABID5NTKFeqw0CCA3hLf8k+PyZtZzrbln /NiM5W7Zr0O9eof5kg0e3P2gzb7oE+SEBFLEt/3sCkXJJmns0pcu9y7fuHysz4gPtigH YUlO3yTAV76CB6lLZSrvEGv/mvVm+wDTC3pjnW26uMr5hzdFo0/nN8oADlg/uqv61vE3 ENAqyI3wRmXV1Q39TVVJGMi34CFSinA2qq9HyEgim6HnSzMmTmWqlwfJBngzXZK90U1o Mqm31tJat8yyg++AEVvnbXu6tQ5IcwcH7balYTHeBH6jw9LmY1N6Hj4kUNRdA5TfLweI tV3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :in-reply-to:references:to:content-language:subject:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=/GYSMh8YUQHJWjKO4P4xa5kndn91rhpd2XxuGubsQb0=; b=pCzfOt2Xdl38LsJhepgA8cgWDmH77MtHM8pZpOFFTS+7YnsICJtQceb1FIHmXmxFBx evNoE+1LqzaR+1wNPBKcJRfTdzB79gCeqakZ8+lETc7/liPu9B2TfOQCa+dNWW7+0EXI 0h0ivQ8JzSsK/K9ATI0Hh5wnMowuvfp9h0iQHUp/MINT3YXbpHkIRaO0aiH0yXCoPqsP Ksgbd+YyVcQnmBuES6N74+f7Y3qUTKq1R4wCi1W//LcDVXI2qnegT5DdaWKX3+a6xMiU rNtLcuyqoRTsFFDkhb7dxyWIhzAhkRMgw0Tm08owhDCt1cwsZ1fDjkwfRFAbkT0SYoX6 uXSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=eV5C+hw5; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id y17-20020a50eb91000000b0043d9a57098asi3415606edr.184.2022.08.05.05.57.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 05:57:42 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=eV5C+hw5; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F0D1F38582BE for ; Fri, 5 Aug 2022 12:57:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0D1F38582BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659704261; bh=/GYSMh8YUQHJWjKO4P4xa5kndn91rhpd2XxuGubsQb0=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=eV5C+hw5soZuAr9ZpMeEyuXZJgvbVToTZm+F6V/gpU1So6/P/EK2bfWPDkMDxn0wz ewcdTRyrdYehUCnGdY+kBwhPZ0SKoN2X2MMw8QUCXpgp564wHx5tTBOB7q4FU0puQw z5tpGqxhTx+SvEWgdgjRdqn4x6QWPB+jrqfEigCY= 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 BFEC6385840B for ; Fri, 5 Aug 2022 12:56:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BFEC6385840B 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 10D76113E; Fri, 5 Aug 2022 05:56:59 -0700 (PDT) Received: from [10.57.14.36] (unknown [10.57.14.36]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A45E03F73B; Fri, 5 Aug 2022 05:56:57 -0700 (PDT) Message-ID: <69a0dc52-4125-1d25-fa2b-4acf6cc3b80f@arm.com> Date: Fri, 5 Aug 2022 13:56:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: [PATCH 3/4] match.pd: Teach forwprop to handle VLA VEC_PERM_EXPRs with VLS CONSTRUCTORs as arguments Content-Language: en-US To: gcc-patches@gcc.gnu.org References: <95d2de77-5b68-6d0b-ac99-ac1ca28835e2@arm.com> In-Reply-To: <95d2de77-5b68-6d0b-ac99-ac1ca28835e2@arm.com> X-Spam-Status: No, score=-23.5 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Andre Vieira \(lists\) via Gcc-patches" From: "Andre Vieira (lists)" Reply-To: "Andre Vieira \(lists\)" Cc: Richard Sandiford Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740326056356656262?= X-GMAIL-MSGID: =?utf-8?q?1740326056356656262?= Hi, This patch is part of the WIP patch that follows in this series. It's goal is to teach forwprop to handle VLA VEC_PERM_EXPRs with VLS CONSTRUCTORs as arguments as preparation for the 'VLA constructor' hook approach. Kind Regards, Andre diff --git a/gcc/match.pd b/gcc/match.pd index 9736393061aac61d4d53aaad6cf6b2c97a7d4679..3c3c0c6a88b35a6e42c506f6c4603680fe6e4318 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -7852,14 +7852,24 @@ and, if (!tree_to_vec_perm_builder (&builder, op2)) return NULL_TREE; + /* FIXME: disable folding of a VEC_PERM_EXPR with a VLA mask and VLS + CONSTRUCTORS, since that would yield a VLA CONSTRUCTOR which we + currently do not support. */ + if (!TYPE_VECTOR_SUBPARTS (type).is_constant () + && (TYPE_VECTOR_SUBPARTS (TREE_TYPE (op0)).is_constant () + || TYPE_VECTOR_SUBPARTS (TREE_TYPE (op1)).is_constant ())) + return NULL_TREE; + /* Create a vec_perm_indices for the integer vector. */ poly_uint64 nelts = TYPE_VECTOR_SUBPARTS (type); bool single_arg = (op0 == op1); vec_perm_indices sel (builder, single_arg ? 1 : 2, nelts); } - (if (sel.series_p (0, 1, 0, 1)) + (if (sel.series_p (0, 1, 0, 1) + && useless_type_conversion_p (type, TREE_TYPE (op0))) { op0; } - (if (sel.series_p (0, 1, nelts, 1)) + (if (sel.series_p (0, 1, nelts, 1) + && useless_type_conversion_p (type, TREE_TYPE (op1))) { op1; } (with { diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc index fdc4bc8909d2763876550e53277ff2b3dcca796a..cda91c21c476ea8611e12c593bfa64e1d71dd29e 100644 --- a/gcc/tree-ssa-forwprop.cc +++ b/gcc/tree-ssa-forwprop.cc @@ -2661,7 +2661,7 @@ simplify_permutation (gimple_stmt_iterator *gsi) /* Shuffle of a constructor. */ bool ret = false; - tree res_type = TREE_TYPE (arg0); + tree res_type = TREE_TYPE (gimple_get_lhs (stmt)); tree opt = fold_ternary (VEC_PERM_EXPR, res_type, arg0, arg1, op2); if (!opt || (TREE_CODE (opt) != CONSTRUCTOR && TREE_CODE (opt) != VECTOR_CST))