From patchwork Mon Apr 24 15:54:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 87099 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2841339vqo; Mon, 24 Apr 2023 08:54:58 -0700 (PDT) X-Google-Smtp-Source: AKy350Yq4SJe+trQYiMsbss+kXr1XgHCAQAwo86kvtBqKtmQWn8D/Po+9BUjRKhAhMUaX4E8kK6o X-Received: by 2002:a17:906:fcd9:b0:94a:56ec:7f12 with SMTP id qx25-20020a170906fcd900b0094a56ec7f12mr9764913ejb.30.1682351697857; Mon, 24 Apr 2023 08:54:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682351697; cv=none; d=google.com; s=arc-20160816; b=QqRjS8DltKE7HQNN3tkjEWaSJuqR6hh+vg5y47tv8YVtDdts+RWUcdX4YEQGgsCq88 0U7p79jwmmn23r8D0Q93BJyTukzmX1cBazFMMEH8eXWRO1mRaIHDMyj7JBMXy4e+ASV9 B2MZ9CmKeJAh0DyE0lUaGbgmhbMb250vATAKrQagJpdjPJewQ1By3aFR10odboBlEyX1 lRfLYoQHBcR83vbNcgCC98HhkBbLGopeQQh/k29Pyi6ph9R8vDvZzULyGYSVff+bA1xC 0nbXtqdnbk5np0BbBq/NWU5Z+00jwfhPWitBJapw0lHuKmH194Tj6OsZ9HjMKjAPpSbH tdng== 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=x28XBuGCUUiKvM5VKse5X8KvHwgeWPyf19sX57DQXRs=; b=TUvDQiHuMXoMZWo9Ejh4A1URFHe6XXhI+h/EUKQhFFyUFB/3nLtcdN7dBKmHiTIDXH tqDvaUvgi1HLVRzHaJmI3bt3N9s3QMw4kWa8SsahUnjmiaZB8hcjnvqIyzRJGwB9GcPy YSH/ochWbjT5fTL1YMxwBqrxhSyRL5cin67ky1GtRBweSB48ct1m6vlnu5U2ontJonZK 85dY0+YgkRXHx+/Ni64l6WIWQYKmwAmxhT6TkimT4XN4XB/R19GuLQJT+D8mPg8KKZLP TBIxZUra1SwlAe7aVykV9T/CQVhAq4c35Ar+FwA2wsdnMAo6GKFxI29w/Jx+AJgM3tMz zzyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=aBRhBKpj; 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 o9-20020a1709062e8900b009571df13713si6032653eji.694.2023.04.24.08.54.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Apr 2023 08:54:57 -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=aBRhBKpj; 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 C13373858409 for ; Mon, 24 Apr 2023 15:54:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C13373858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682351696; bh=x28XBuGCUUiKvM5VKse5X8KvHwgeWPyf19sX57DQXRs=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=aBRhBKpjf5HZV6klg13XlD+fvakhu6eL9/5qvK4vP6WHBfMl+nzDcwLRDcBSkLR5p mBIbBMAcHt3WJHwj3t2+ICDGwkw/hIRfVKryn5agp7cPzcxQx4DHplRnIdV2l9/Qux 5Wm3Y2KDUuLNx5QV1DahTDkYImX/Tq3ILX01J1I8= 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 CBC353858D1E for ; Mon, 24 Apr 2023 15:54:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CBC353858D1E 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-78-iy2LqOAiOny7Ar_Qy90hvA-1; Mon, 24 Apr 2023 11:54:09 -0400 X-MC-Unique: iy2LqOAiOny7Ar_Qy90hvA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A8D811C0A584; Mon, 24 Apr 2023 15:54:08 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.156]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6443B492C13; Mon, 24 Apr 2023 15:54:07 +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 33OFs4HJ2356036 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 24 Apr 2023 17:54:04 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 33OFs3Qs2356035; Mon, 24 Apr 2023 17:54:03 +0200 Date: Mon, 24 Apr 2023 17:54:02 +0200 To: David Edelsohn , Segher Boessenkool , Kewen Lin Cc: gcc-patches@gcc.gnu.org, Xionghu Luo Subject: [PATCH] powerpc: Fix up *branch_anddi3_dot for -m32 -mpowerpc64 [PR109566] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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?1764073613845103618?= X-GMAIL-MSGID: =?utf-8?q?1764073613845103618?= Hi! The following testcase reduced from newlib ICEs on powerpc-linux, with -O2 -m32 -mpowerpc64 since r12-6433 PR102239 optimization was added and on the original testcase since some ranger improvements in GCC 13 made it no longer latent on newlib. The problem is that the *branch_anddi3_dot define_insn_and_split relies on the *rotldi3_mask_dot define_insn_and_split being recognized during splitting. The rs6000_is_valid_rotate_dot_mask function checks whether the mask is a CONST_INT which is a valid mask, but *rotl3_mask_dot in addition to checking that it is a valid mask also has (mode == Pmode || UINTVAL (operands[3]) <= 0x7fffffff) test in the condition. For TARGET_64BIT that doesn't add any further requirements, but for !TARGET_64BIT && TARGET_POWERPC64 if the AND second operand is larger than INT_MAX it will not be recognized. The rs6000_is_valid_rotate_dot_mask function is used solely in one spot, condition of *branch_anddi3_dot, so the following patch adjusts it to check for that as well. Bootstrapped/regtested on powerpc64-linux (-m32/-m64) and powerpc64le-linux, ok for trunk/13.1/12.3? 2023-04-24 Jakub Jelinek PR target/109566 * config/rs6000/rs6000.cc (rs6000_is_valid_rotate_dot_mask): For !TARGET_64BIT, don't return true if UINTVAL (mask) << (63 - nb) is larger than signed int maximum. * gcc.target/powerpc/pr109566.c: New test. Jakub --- gcc/config/rs6000/rs6000.cc.jj 2023-04-04 10:33:47.433201866 +0200 +++ gcc/config/rs6000/rs6000.cc 2023-04-24 12:31:07.237031550 +0200 @@ -11409,7 +11409,16 @@ bool rs6000_is_valid_rotate_dot_mask (rtx mask, machine_mode mode) { int nb, ne; - return rs6000_is_valid_mask (mask, &nb, &ne, mode) && nb >= ne && ne > 0; + if (rs6000_is_valid_mask (mask, &nb, &ne, mode) && nb >= ne && ne > 0) + { + if (TARGET_64BIT) + return true; + /* *rotldi3_mask_dot requires for -m32 -mpowerpc64 that the mask is + <= 0x7ffffff. */ + return (UINTVAL (mask) << (63 - nb)) <= 0x7fffffff; + } + else + return false; } /* Return whether MASK (a CONST_INT) is a valid mask for any rlwinm, rldicl, --- gcc/testsuite/gcc.target/powerpc/pr109566.c.jj 2023-04-24 12:54:48.293266468 +0200 +++ gcc/testsuite/gcc.target/powerpc/pr109566.c 2023-04-24 12:34:34.306006418 +0200 @@ -0,0 +1,15 @@ +/* PR target/109566 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mpowerpc64" } */ + +void +foo (double x) +{ + union { double d; unsigned i; } u; + u.d = x; + if (u.i & 0x7ff00000) + return; + else + for (;;) + ; +}