From patchwork Fri Apr 21 11:59:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 86266 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1009459vqo; Fri, 21 Apr 2023 05:01:01 -0700 (PDT) X-Google-Smtp-Source: AKy350bFTV4IusAOAQdCsNDM/7lvzr8RFOue9VZMAU4Iqb1LgkYtihLD+poqFoci3sSu02ofPDiH X-Received: by 2002:aa7:c907:0:b0:508:4014:ae3a with SMTP id b7-20020aa7c907000000b005084014ae3amr4822935edt.39.1682078461620; Fri, 21 Apr 2023 05:01:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682078461; cv=none; d=google.com; s=arc-20160816; b=q0cRADI1bL8XVKV4o2/sSxRFyiRTIK59zU1ECFpzi18cliZ8udi5BtfZ+ESMOL0IN4 Ej/cS1Hi6Z6IsbLx95yQZdZAVJEiGZlQhNdfb1zx54tRsQtBddvPiGXqdZjSOGdzOpy6 EXbz+gMdhUiVVkQZ7XVc78Fh3JWaAXGnts77iuEIa8sO1KhIGeezrNS4CN8D+QLKT/nx 5i0NGgmsMpxun4zLK1TrP6o2I+DOMflGEiOiThjLTh3eeQ8jWBD91zkv/CAdvTbTCFF5 43ZFG/KZJArJdUO0jlJKDIdYNTs5H9l7P946YrC4J9M5Ua7ubOmk418Nb6UNDQ9CcgU/ q/DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=jgsKGBHdJVhIbbgjw0gdeAMsYvzji066f+pzngYa7BE=; b=X/8qZuWtF/rFVxXUGx0IpAhps2nH3wfdiAwBQGHy3KRAt6EfUb1zV1lX9mF1yJOIfo 1pPtzSrUKtTbJV0SM1d2+5tANqdop5vRb6gPz1CYeoXwlJifnOksyGZw8RV+r6+sVs9b JWPK0LWZfhAh1nOnBJjUvfJcMsXBuFjCn+fUI+X0qWXY872ahxK7OfnyQ5NUXSMzfebG ZZuSuA26s3Q5sTY2kQaya9arYEwT8suBhyE8KuNUNg+s0Rxk5q8N3arb2UCPUq/vcMpg tAP3kXVuege0KMmZ8MpWq6QKbu5PyO90PWTZM1fmGo0lRM0j01NnYlx+3AZ3yWg+YcOL cGGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=OB3OdmFy; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p18-20020a05640210d200b00506a7d9c0fdsi3688275edu.133.2023.04.21.05.01.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 05:01:01 -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=OB3OdmFy; 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 3D48538555B7 for ; Fri, 21 Apr 2023 12:00:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D48538555B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682078431; bh=jgsKGBHdJVhIbbgjw0gdeAMsYvzji066f+pzngYa7BE=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=OB3OdmFyn4+LCHxFGoeoXViBPBOva7mnntWSK7zDi8h9RYakHB5Mlc+w/uGy+jpZ2 GFVsHdLUDpXLaXiI9ox1BdijiyhXqu5j4FQeiG0nwWgroDTCtHIG44Ewi48DYqUFp4 ZkT7sW5uRJvZu9R2dVcCeu8AuK0to48VeQBhjsAI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 237423857714 for ; Fri, 21 Apr 2023 11:59:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 237423857714 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-152-LN8WWsCqNk6PrvmXLY_wzw-1; Fri, 21 Apr 2023 07:59:41 -0400 X-MC-Unique: LN8WWsCqNk6PrvmXLY_wzw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0FE23280A330; Fri, 21 Apr 2023 11:59:41 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C07792026D16; Fri, 21 Apr 2023 11:59:40 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 33LBxcEB4193454 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Apr 2023 13:59:38 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 33LBxaXZ4193453; Fri, 21 Apr 2023 13:59:36 +0200 Date: Fri, 21 Apr 2023 13:59:35 +0200 To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] match.pd: Fix fneg/fadd optimization [PR109583] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek 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?1763787105217060672?= X-GMAIL-MSGID: =?utf-8?q?1763787105217060672?= Hi! The following testcase ICEs on x86, foo function since my r14-22 improvement, but bar already since r13-4122. The problem is the same, in the if expression related_vector_mode is called and that starts with gcc_assert (VECTOR_MODE_P (vector_mode)); but nothing in the fneg/fadd match.pd pattern actually checks if the VEC_PERM type has VECTOR_MODE_P (vec_mode). In this case it has BLKmode and so it ICEs. The following patch makes sure we don't ICE on it. Ok for trunk and 13.1 (it is a 13/14 Regression and I think the fix is quite obvious and safe) if it passes bootstrap/regtest? 2023-04-21 Jakub Jelinek PR tree-optimization/109583 * match.pd (fneg/fadd simplify): Don't call related_vector_mode if vec_mode is not VECTOR_MODE_P. * gcc.dg/pr109583.c: New test. Jakub --- gcc/match.pd.jj 2023-04-18 11:01:38.867871375 +0200 +++ gcc/match.pd 2023-04-21 13:26:01.250166206 +0200 @@ -8103,7 +8103,8 @@ and, poly_uint64 wide_nunits; scalar_mode inner_mode = GET_MODE_INNER (vec_mode); } - (if (sel.series_p (0, 2, 0, 2) + (if (VECTOR_MODE_P (vec_mode) + && sel.series_p (0, 2, 0, 2) && sel.series_p (1, 2, nelts + 1, 2) && GET_MODE_2XWIDER_MODE (inner_mode).exists (&wide_elt_mode) && multiple_p (GET_MODE_NUNITS (vec_mode), 2, &wide_nunits) --- gcc/testsuite/gcc.dg/pr109583.c.jj 2023-04-21 13:28:36.462911138 +0200 +++ gcc/testsuite/gcc.dg/pr109583.c 2023-04-21 13:28:06.746342736 +0200 @@ -0,0 +1,25 @@ +/* PR tree-optimization/109583 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -Wno-psabi" } */ +/* { dg-additional-options "-mno-avx" { target i?86-*-* x86_64-*-* } } */ + +typedef float v8sf __attribute__((vector_size (8 * sizeof (float)))); +typedef int v8si __attribute__((vector_size (8 * sizeof (int)))); + +#if __SIZEOF_INT__ == __SIZEOF_FLOAT__ +v8sf +foo (v8sf x, v8sf y) +{ + v8sf a = x - y; + v8sf b = x + y; + return __builtin_shuffle (a, b, (v8si) { 0, 9, 2, 11, 4, 13, 6, 15 }); +} + +v8sf +bar (v8sf x, v8sf y) +{ + v8sf a = x + y; + v8sf b = x - y; + return __builtin_shuffle (a, b, (v8si) { 0, 9, 2, 11, 4, 13, 6, 15 }); +} +#endif