From patchwork Sun Jul 2 14:53:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 115099 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp433vqx; Sun, 2 Jul 2023 07:54:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7BDgywfir+gKNLID/5ipU0izV1R9kEVMTqnNg+pSNzJw2TA6AXl6R7rvMZxmips7zCzeY0 X-Received: by 2002:a7b:cbd6:0:b0:3fa:8fc2:3969 with SMTP id n22-20020a7bcbd6000000b003fa8fc23969mr6882530wmi.17.1688309671375; Sun, 02 Jul 2023 07:54:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688309671; cv=none; d=google.com; s=arc-20160816; b=XrafgTEOyNSgsTtTtxW8xqqg7r5p28HyycIEK38U6XYYqrEjISxb5ErDS3AGourx+8 p0KdUaMHJftcowPuV1Kazr9gGKSZY7zWrmngVxeCFTZaALLWA/+TtD2ij0sVZ4ZHgmQW SU6mhTSg7JMmIdtk4tyPG4W2fmJoW6IssIL7XbYSDsjVn+0O3L3EKB2OaLdxPfzab+Ib ZR6ZOEgOx7IeDe//4gG/qu7ZKxpExfBEofPFmQoLFZP7mppSRPL5Q8WNlMPaizClfmcf 3jaAD+fNMcBfxB6viDkFjCeMjsmpiKERU+XrjWKQK2fBrI9YJgZKNZ7vYTlUmW6yaK7T 65Zg== 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=/ZyHEUnqf/oEgcjFCJSHgRLaBjTZiFHMIxjFGmXN2oY=; fh=FCjeRajqaQYHMkQtfIia8KT5yBac53mYOLLyJhYG/AY=; b=tenQAta2YDWiw/rdb7RDzCnJoxFHfvgcH7b4hd8YcnInMkU/xryNZ/acvgTdq0ZN6p hIPwT5/vkfkVy1LKLOXu4T5lKUY7DCQ6NGmlY4d61A/P53t9Tfwpey0VimJyhK7S+AWB BVFvOlIgIBu7CZuuxdZ0xOVvn3GRjEWdQQiR7nXE1zRNN2PnYbzjmwy0pANv88hk5SHn 8mx36F4agxLe0wgHk7KE5rtzLBB9NRwZ7w6l1jc8K5byWvNYBC5ag8BoilXaPyRNijlZ E3kqf1IA7a1yXku/Zf7m3ZGGlhR7EhgnTYRHlJ2juU801papZxhk97ce5C0ZXxK1aROz 28HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QbJWeh6g; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id k25-20020a17090666d900b0098882e012dasi2100029ejp.443.2023.07.02.07.54.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jul 2023 07:54:31 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QbJWeh6g; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 D1EC03858422 for ; Sun, 2 Jul 2023 14:54:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1EC03858422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688309669; bh=/ZyHEUnqf/oEgcjFCJSHgRLaBjTZiFHMIxjFGmXN2oY=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=QbJWeh6gBjXt+Q0lU+TPEShWl1UikoRSUjOK1q9OlNzGFCzKXlNECmRzpAYguFK7N x+YhMD3w8qUAkErCV9gEZCH7JtaZYkHT2Ma9Y/T8gtoU8vvSeA9IXfFbaV46jhUVLS FUXsdeZGHcYQUUi1oNGnaU8gposm2CPjKR7NUhXg= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 4A2023858412 for ; Sun, 2 Jul 2023 14:53:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4A2023858412 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-353-kVj_n4W6NYmmzLoJ9eHW3g-1; Sun, 02 Jul 2023 10:53:46 -0400 X-MC-Unique: kVj_n4W6NYmmzLoJ9eHW3g-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 172D0858EED; Sun, 2 Jul 2023 14:53:46 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.167]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D20BB492C13; Sun, 2 Jul 2023 14:53:45 +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 362Erh4V3533217 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 2 Jul 2023 16:53:43 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 362ErgFZ3533216; Sun, 2 Jul 2023 16:53:42 +0200 Date: Sun, 2 Jul 2023 16:53:42 +0200 To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-ssa-math-opts: Fix up ICE in match_uaddc_usubc [PR110508] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.4 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_H4, RCVD_IN_MSPIKE_WL, 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?1770321001897611762?= X-GMAIL-MSGID: =?utf-8?q?1770321001897611762?= Hi! The match_uaddc_usubc matching doesn't require that the second .{ADD,SUB}_OVERFLOW has REALPART_EXPR of its lhs used, only that there is at most one. So, in the weird case where the REALPART_EXPR of it isn't present, we shouldn't ICE trying to replace that REALPART_EXPR with REALPART_EXPR of .U{ADD,SUB}C result. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-07-02 Jakub Jelinek PR tree-optimization/110508 * tree-ssa-math-opts.cc (match_uaddc_usubc): Only replace re2 with REALPART_EXPR opf nlhs if re2 is non-NULL. * gcc.dg/pr110508.c: New test. Jakub --- gcc/tree-ssa-math-opts.cc.jj 2023-06-20 11:22:26.726887276 +0200 +++ gcc/tree-ssa-math-opts.cc 2023-07-01 00:29:48.554230914 +0200 @@ -4856,11 +4856,14 @@ match_uaddc_usubc (gimple_stmt_iterator gsi_remove (&gsi2, true); /* Replace the re2 statement with __real__ of the newly added .UADDC/.USUBC call. */ - gsi2 = gsi_for_stmt (re2); - tree rlhs = gimple_assign_lhs (re2); - g = gimple_build_assign (rlhs, REALPART_EXPR, - build1 (REALPART_EXPR, TREE_TYPE (rlhs), nlhs)); - gsi_replace (&gsi2, g, true); + if (re2) + { + gsi2 = gsi_for_stmt (re2); + tree rlhs = gimple_assign_lhs (re2); + g = gimple_build_assign (rlhs, REALPART_EXPR, + build1 (REALPART_EXPR, TREE_TYPE (rlhs), nlhs)); + gsi_replace (&gsi2, g, true); + } if (rhs[2]) { /* If this is the arg1 + arg2 + (ovf1 + ovf2) or --- gcc/testsuite/gcc.dg/pr110508.c.jj 2023-07-01 00:33:12.494405901 +0200 +++ gcc/testsuite/gcc.dg/pr110508.c 2023-07-01 00:32:24.115075870 +0200 @@ -0,0 +1,9 @@ +/* PR tree-optimization/110508 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +foo (unsigned a, unsigned b, unsigned *c, _Bool d) +{ + __builtin_addc (a, b, d, c); +}