From patchwork Tue Aug 24 02:00:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 1520064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nextmovesoftware.com header.i=@nextmovesoftware.com header.a=rsa-sha256 header.s=default header.b=AWp0li6E; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gtslv66K8z9sW8 for ; Tue, 24 Aug 2021 12:01:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 934CB3857831 for ; Tue, 24 Aug 2021 02:01:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id 33AC43857C53 for ; Tue, 24 Aug 2021 02:00:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 33AC43857C53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=j0z/TpztMnRd+5W+VjSEjEVFB6YFbUjnty+Buja1YCk=; b=AWp0li6EMl1d5O6393CNLXaV7S pZ7lJey6gX2wMiv97HqH/P9dDbejtzpKGItmVPQY5pxGykyRY3NQhKjbs0y5Ibi+wRxwmejL0vn4B mdI+TAA+3YWfWLsRBoiF0dNot++HO2Q2HnZF8hCr2dOMe+SjDxJXoXhZ70iJYybZjwyhSVrWNmREa 5Ts0HHMU9ipvaGlV7K42eHyorKwkNF9Ywk8qzqKuKavgONu9t5LbI1xI4sixw4WTALMueeCUzs6M8 HbLI1uF0iffbh2K4ELhdAA8Y98dxYikJbapOtEJfKDxjWaqPDjj7G7NBdThWSsiLVXvC09wDy9YHc n7AjsVHA==; Received: from host86-163-217-120.range86-163.btcentralplus.com ([86.163.217.120]:52857 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mILjr-0002Nw-L0; Mon, 23 Aug 2021 22:00:31 -0400 From: "Roger Sayle" To: "'GCC Patches'" Subject: [Committed] PR middle-end/102029: Stricter typing in LSHIFT_EXPR sign folding. Date: Tue, 24 Aug 2021 03:00:29 +0100 Message-ID: <001f01d7988b$d17634e0$74629ea0$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdeYexnaDJBuAGGgQrOSLHC0gy4u4Q== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Cc: 'Jakub Jelinek' Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" My sincere apologies to everyone (again). As diagnosed by Jakub Jelinek, my recent patch to fold the signedness of LSHIFT_EXPR needs to be careful not to attempt transforming a left shift in an integer type into an invalid left shift of a pointer type. This patch has been committed as obvious, after testing that a "make bootstrap" on x86_64-pc-linux-gnu is unaffected [make -k check is underway]. Sorry (yet) again. 2021-08-23 Roger Sayle Jakub Jelinek gcc/ChangeLog PR middle-end/102029 * match.pd (shift transformations): Add an additional check for !POINTER_TYPE_P in the recently added left shift transformation. gcc/testsuite/ChangeLog PR middle-end/102029 * gcc.dg/fold-convlshift-3.c: New test case. Roger --- /* PR middle-end/102029 */ /* { dg-do compile } */ /* { dg-options "-O2" } */ int * foo (const __PTRDIFF_TYPE__ l) { return (int *) (l << 2); } diff --git a/gcc/match.pd b/gcc/match.pd index 978a1b0..e5bbb12 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3389,7 +3389,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) the form that minimizes the number of conversions. */ (simplify (convert (lshift:s@0 (convert:s@1 @2) INTEGER_CST@3)) - (if (tree_nop_conversion_p (type, TREE_TYPE (@0)) + (if (INTEGRAL_TYPE_P (type) + && !POINTER_TYPE_P (type) + && tree_nop_conversion_p (type, TREE_TYPE (@0)) && INTEGRAL_TYPE_P (TREE_TYPE (@2)) && TYPE_PRECISION (TREE_TYPE (@2)) <= TYPE_PRECISION (type)) (lshift (convert @2) @3)))