From patchwork Thu Apr 27 11:21:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 88206 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp193059vqo; Thu, 27 Apr 2023 04:22:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Xvb7jkzuYBKi+bthr9DwoUqQYq6m0tPRKq+m52s7sIpB7m2KqNo69vLfFJTWB5fYdA81d X-Received: by 2002:a17:907:2cc2:b0:957:12b6:8918 with SMTP id hg2-20020a1709072cc200b0095712b68918mr1277888ejc.75.1682594540807; Thu, 27 Apr 2023 04:22:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682594540; cv=none; d=google.com; s=arc-20160816; b=GoCk0L/8EfNEIRgKDZiSKjm6ewIyzrYq76FAEKZySR0UAwsZJVDFS0MWjIQgTSCCEK MaJUZp+OX8Q2CMvKiw8aUtZgtDuJ/Xeqgd2qLiq3j9h1F2B84u3jUmXFW03GJclENPDw xa/Y6Arl6942UU4tYJCF8la+kn9b4H3NhL+9OdfPy3bVhFlqRWwgdB1tccajg/elsDs4 98v+R9lLjkOp/WlYHkl6YCYM/pP41o7ND9qm9F5obL+0eIWnLOkZcEu79nU9XZy6yCN6 qJSKSFb0dodA1iHf0/0ALb8X/lg2IY7wjM6wTgFP+MUVzrkQBLWrPlKcQCdSlvs1WUBk ry/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=RvZyulhl6q8s/OmZMu/b26lCOwm+2OthPrR458cR7CU=; b=eeycAuCeuer2b95HJz5ggA4/8ojsaB44xYsiasS/XZyJgSnY8cMLC+EVUgGS4GgCi1 1LQOzsnAlXmgOk7NNDVIQmX45ADSp7LWdTxtsR3m1rl9oSMLy0Ea4vFwoz4LRKyv9fbL C5OEfZQPtMz82MzM+IExFw5S3iRbgGGHsrNhQZA+ORb3c1ma7AWjGE8+pUabSGJlZA43 UKBPlaBnZzeVkmllCPaYvB3FDw1ZzPp0AzweaAATWocHF7VT+5nAk82rCf6G65MS+NGP P9GKmn+1tOMdqFonpnMFfJomXZx3Vgz6iPUyPJRO91C+amYohED3tybI3j+EGbKgBa9g ToiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="vF+yT/ev"; 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 y22-20020a17090629d600b0094eebebe284si13934277eje.116.2023.04.27.04.22.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 04:22:20 -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="vF+yT/ev"; 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 AC33F3858418 for ; Thu, 27 Apr 2023 11:22:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC33F3858418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682594539; bh=RvZyulhl6q8s/OmZMu/b26lCOwm+2OthPrR458cR7CU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vF+yT/evuhdbqpZuZnoJ2GX2DTojHtmoHwsjgElcJD+yv0PW62PPTgbqLCgIY+wN2 Ku6p62zIegNZgbeIrpe7WzQxAoviGvnqFAfzuyfeqPmpOqFmnK3AXNy2rovTYPTKv1 ga9l1LJ0yY7QlK91+B+hJqhE8d1UHXBa9WGDofc4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 445343858D33 for ; Thu, 27 Apr 2023 11:21:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 445343858D33 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 71E0F21AD6 for ; Thu, 27 Apr 2023 11:21:35 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 6BB1A2C141 for ; Thu, 27 Apr 2023 11:21:35 +0000 (UTC) Date: Thu, 27 Apr 2023 11:21:35 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] wrong GIMPLE from (bit_field_ref CTOR ..) simplification User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, 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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" Message-Id: <20230427112219.AC33F3858418@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764328253156117149?= X-GMAIL-MSGID: =?utf-8?q?1764328253156117149?= When we simplify a BIT_FIELD_REF of a CTOR like { _1, _2, _3, _4 } and attempt to produce (view converted) { _1, _2 } for a selected subset we fail to realize this cannot be done from match.pd since we have no way to write the resulting CTOR "operation" and the built CTOR { _1, _2 } isn't a GIMPLE value. This kind of simplifications have to be done in forwprop (or would need a match.pd syntax extension) where we can split out the CTOR to a separate stmt. The following disables this particular simplification when we are simplifying GIMPLE. With enhanced IL checking this otherwise causes ICEs in the testsuite from vectorized code. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * match.pd (BIT_FIELD_REF CONSTRUCTOR@0 @1 @2): Do not create a CTOR operand in the result when simplifying GIMPLE. --- gcc/match.pd | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 34e1a5c1b46..c4320781f5b 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -7456,10 +7456,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) ? type : build_vector_type (TREE_TYPE (TREE_TYPE (ctor)), count * k)); + /* We used to build a CTOR in the non-constant case here + but that's not a GIMPLE value. We'd have to expose this + operation somehow so the code generation can properly + split it out to a separate stmt. */ res = (constant_p ? build_vector_from_ctor (evtype, vals) - : build_constructor (evtype, vals)); + : (GIMPLE ? NULL_TREE : build_constructor (evtype, vals))); } - (view_convert { res; })))))) + (if (res) + (view_convert { res; }))))))) /* The bitfield references a single constructor element. */ (if (k.is_constant (&const_k) && idx + n <= (idx / const_k + 1) * const_k)