From patchwork Thu Jul 28 16:44:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Richard Earnshaw (lists)" X-Patchwork-Id: 273 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp340336pxt; Thu, 28 Jul 2022 09:45:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sfMH5EgjiTqM4+U6beKu5iv163Ui6R6+zlysOpX5bRvBnmt+CRqSWFJaTkOwNqlU0CyFZ5 X-Received: by 2002:a17:906:ef8b:b0:72b:4a67:8ae5 with SMTP id ze11-20020a170906ef8b00b0072b4a678ae5mr21836289ejb.763.1659026712050; Thu, 28 Jul 2022 09:45:12 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 23-20020a508757000000b0043be308c841si1185058edv.251.2022.07.28.09.45.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 09:45:12 -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=skTKZFIe; arc=fail (signature failed); 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 EC977385AE44 for ; Thu, 28 Jul 2022 16:45:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC977385AE44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659026708; bh=NJHbht9pP/WMzdlLpiCe/BwfGUYC7vrDV522c0bCFsk=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=skTKZFIey8FbAW6KTa5Z2V61tG+CHeb732B3VSXcXskn/fWHKcAj880iY+un2SHig OE5EloUDVecezRmmMknoOI47inYNdoctMqJ1XbUKPCDWiOEvLOrDFE6FKunsiYzMVA LMTbzouS+LqA11PcHA3xSI1qCwXLGfpwAmkrtWPs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2071.outbound.protection.outlook.com [40.107.21.71]) by sourceware.org (Postfix) with ESMTPS id 1A5073857C5F for ; Thu, 28 Jul 2022 16:44:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1A5073857C5F ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=E4plVvOksaM3hL9OoIggUhwY0/IesuCq6pdsxELtqWxB2w+80YiHnbyjUawR8Mfw3histwpWHqT+gqW90UPdkiYQ5oymxwnD8Udtm2ZJWDpijZcjvGcHKGRjOE/d9h6/bMT3ROMPOqchnHlnT96KOPfUraLKBY0FshBoWY3h3N18wL8fa0o+ZKzHHV4AYLWHPl9pSLGl5TFV3/2lFUO0c7u+row32BoPLaPWWPZXYJ2N0SB4mJX36wmzHw2pVy5a8GfK8uGwhB69ydCXx4mokZrBpTxEymiKL+Py5V0nsojylqtztShgpZYBCpvoVbQzwzRJJ8Nshcgqn7oUBRFiGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NJHbht9pP/WMzdlLpiCe/BwfGUYC7vrDV522c0bCFsk=; b=dMHhYOQyBXbu3YEs13YXUmw+GX9J2K110ST482/feO6O6sS98/P0Nvjop718GWT1NlQ09oOtbcjjEWRS927ePRlwpulXgC9w51wcf3gqY+ivolic+o8a0H4LayVUcgNJz+rAJIpuRVNjMctRXYh6RlQn1f1s5PmwGBLg7d+ThvoX8C6Ru9WrImwuJEbLBD2N+3sOF5ttKARuperMDPrcSd30hKyVlrhvNi0JgbrwKlMYMK/91+eAMIjRf2yckfhM7L3Neg61wMfaMkcVtkJR491gv/5DjAObLyiuW28y7xeULkok3d9dl4L/uo+iyKwdKH7olQCUsbV0rzlpg3aA6A== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AS8P189CA0017.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:31f::12) by DB9PR08MB6443.eurprd08.prod.outlook.com (2603:10a6:10:261::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.10; Thu, 28 Jul 2022 16:44:17 +0000 Received: from AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31f:cafe::ab) by AS8P189CA0017.outlook.office365.com (2603:10a6:20b:31f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 16:44:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT032.mail.protection.outlook.com (10.152.16.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.12 via Frontend Transport; Thu, 28 Jul 2022 16:44:17 +0000 Received: ("Tessian outbound 73dd6a25223d:v123"); Thu, 28 Jul 2022 16:44:17 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f3f376b28bb20cfa X-CR-MTA-TID: 64aa7808 Received: from a1aa067f88d0.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id ACD978FC-629E-4B72-ACF5-CCB5A8CC0463.1; Thu, 28 Jul 2022 16:44:10 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a1aa067f88d0.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 28 Jul 2022 16:44:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IDxcBzG80Px60xlNVeL8Oaw+n6d8ppXXXtGfjwoxXz0+sCp1gaiQwPaIK7zgHlkXHOYAm2O/WW5P2bLJposXO8swPtHqlMMAdcmUFvP8B/rueW0IHZu7G/99AhKSf/OoZOG0SKWxWXH2fhGOstj136dbViq6v75FQAFvLLoVh9jzvu+T8AEAkh6Boasn+L1+bA9fsCoqW+pK/Ktks2CVrMj+mA+mUcpAz4LAiJnUK+1Lulvjxhnf5GJ5i8facRMqCJA3SXCINNBUu7tEepsAC33CrAVGVtLs/2849O7T58+yqAzFImndFxPKlKv8SelqYFNawt37x7IMJ/TtyHIojw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NJHbht9pP/WMzdlLpiCe/BwfGUYC7vrDV522c0bCFsk=; b=RmUl6QtjoX1yIiG6kA+GsVzKzhKMOQSeAsGd4WT7Gh0c3MA7Srm5UsqbVruxM7m1ES7JIdqWa7AlYi+CNAjKZPR9pZdn2BlGAVsDNQFZ1pEdhqWwUXLTk3kwZJZCVO8eHq0ZzJxQ+FQWdRe7hirGx1ElZ39WNXs+AMd2dywoyeJzBMikarTLqQVCZBgRwvOqDQocw0gKWMQgnHLo3f1bDUnT30L1Un7AqZJ83C/HHsM06S5nN1D9xKWczW1lc5iIZIw3L8G2ipHNxPRhWPDdks+JbGhyP/nHyK3iNp+LZKqqJ2DReh3BTouurEawfAz/sFFsZ5ibHjLwMSYoLmGhaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DB9PR08MB7115.eurprd08.prod.outlook.com (2603:10a6:10:2c8::5) by AM0PR08MB3587.eurprd08.prod.outlook.com (2603:10a6:208:dd::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.10; Thu, 28 Jul 2022 16:44:09 +0000 Received: from DB9PR08MB7115.eurprd08.prod.outlook.com ([fe80::583a:e544:1057:9d7b]) by DB9PR08MB7115.eurprd08.prod.outlook.com ([fe80::583a:e544:1057:9d7b%8]) with mapi id 15.20.5482.010; Thu, 28 Jul 2022 16:44:09 +0000 Message-ID: <8e1a0791-70f7-c9c9-5f3f-1645bb6aaa47@arm.com> Date: Thu, 28 Jul 2022 17:44:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-GB To: "gcc-patches@gcc.gnu.org" , Richard Biener Subject: http://pdtlreviewboard.cambridge.arm.com/r/16099/ Organization: Arm Ltd X-ClientProxiedBy: LO4P265CA0058.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2af::8) To DB9PR08MB7115.eurprd08.prod.outlook.com (2603:10a6:10:2c8::5) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 156dcbcf-644c-46eb-1c25-08da70b86995 X-MS-TrafficTypeDiagnostic: AM0PR08MB3587:EE_|AM5EUR03FT032:EE_|DB9PR08MB6443:EE_ x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Yl5uckXOXAfXxpL8yxrL0KjQuUlW20rWXzGhPHd0VFihaFPxS4wkHPoLlRW7CkUQ8yQ5TTtbYU5Oc9ZA+lN0zhNDEP+KBWibaJ/gOdeFyNfjg2JxmOZCvsK/CorAQmrwnA03Lzi+8Y/TTG42qhvy+w8MapZzrTrzQoL9iZuIlo5AO8K7oVMU0icgdkHOVeIdHHY1Sn/EUgFSQtKqdZ/K3YOHW568DMGQan8MTSWEPGm1Tbl5WWI+56DKWtWPvTD2UL5iMVOxDJ6JJZS/cjH8sq87vQBU7HME/bfGJ80ELofe+lZIxw0lwSDq7HzfglA48WiuN6zwt4p/pOtU8Y2hpzyeze1tpmbyEXsAXangWJAcFWrcjHbslx13qd+0mgSr9jyVwwT57awc/L5EpwK7wcLbv5nMdHhChdBReUko1Nl9OVu/f8C1Oj2hObXKWw8hX5jQPXmZKEk8rEfqJwJzFVvfW4mijxnpfpDRLDo4Vy1m+KpE0dWiorBwL0YTv5eir7UAPkVSQfrKqouz8iCdN+hfT5tryMAz/B1ocO2Ro7NWs1XL5qwO5phuV/hNoaE8Hs81MUb2JfU7J7Lmk94CuTAd8o4KbYt28o00mlOfHuUaUsCUridnqpW9Cfjze6/qHK6JpsORcMvPjLcN+6tQJeJnLM8WkpzVZNw8z6pAQAyWj0DDKyTpC6hZD3eFWHHoGpIo2frNvA+DV3kr5efXzzlWEO0uumh0hutIxLphL+RqAc1IfnYtg1Qw/l03dM2O36XZoGAK0XisqNiUiuCQALEGteBD/vZFT2tdqpVhCpa/sf9n4H24+eIutptolgdqYDQXQoz0WmE+S3pWaH/T3+v66UZuDwND9cM/pqk046rnaLGOOMc1Wb92PF2grb7rklhLtltJKN7Egq7jdXZj0w== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB7115.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39860400002)(366004)(376002)(346002)(396003)(136003)(38100700002)(36916002)(6506007)(33964004)(41300700001)(2906002)(83380400001)(6666004)(6512007)(186003)(2616005)(26005)(316002)(36756003)(66946007)(8676002)(110136005)(478600001)(66476007)(66556008)(31686004)(31696002)(6486002)(86362001)(5660300002)(235185007)(8936002)(232243001)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3587 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b5bea4af-5f68-4d5e-b52b-08da70b86466 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9fuLTB8oIUCdY8D9Ta740b20BG1aw2P9MwFGjSxW/PB0wqczQvFhFHZsDe3Bc/Q8MLy/GYPo6+82J+gy0/Y/TlW8CEcxSIFsYd7rUOo/x8q765sUOY8Jtai/ugqJ1APnp8bXmsUKueJ/uHLlNbRv8Vyl8YEfL+yy1YnzhsA92HwbvNs6njerG+ktL5bsD8ruFSnNAHCw0vY1ne+u3+Z2Nyv6coKb+how2kuRPV4ZV8oahHuIJqaIZlTsk+s125P0jAKbX8tkyBswqUJgatl13+aoDkrixn+gvc49d37DURSD6598zAgJKiuHUClQVxlD7irVpmNWlEELrgAom/GIWF7iWkoCoJUQWQ138oJz9SZKGuNDft8aBcrfQUodTSNsN8AXljUvNtol/YX0IbJSVN9ZIetQ5W3lMZ/CnZZHfZyPOmcBipTt2jc2PXxvk6k7DjAkUVh232V5IW4KOUXX7BXmHWZ6GElptEWtLM08Hbga1OtKv4z5PwIseYf4vgUQJfa3jpQH1cUC1Jn1CRKAlQFYk5DuqiYpJ12zgcm+2e7mQMytoS+wtm2VDF4+NuBFKOIsVeFP6hP0yRvlUI0iV+dx7cGRGyL1qmrOI982K7pQWNgJffV8AnYxeZyRnhwTqbC00HQ2Lwd6AXe4Gskeft/ElLdzp/gAIQXivYh6Ns/CNJ0DyKw0esZIgN+aPCTaxs4d+XYChpuHU5laAy8nNV52q3TlOr/DhOkZJszuN6GvX0zTRJkpo4/4dZMP+/ez9YmYVoMKJzmny2b3yzZMgicRgz4vLWqaTvHeNbMfiQ1xv9bNsUWE9eHZ68eYOT/G1QANL/EBdDCJJwjSHt4GxaIHLpG8TQt0Jc/0Jk4EXDRrd7Gt4OxN2T94CKQeOWW1K4ZITH3hCyxvguPlmYK/8Q== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230016)(4636009)(396003)(39860400002)(136003)(376002)(346002)(40470700004)(46966006)(36840700001)(36860700001)(81166007)(31686004)(110136005)(6486002)(356005)(82740400003)(41300700001)(36756003)(86362001)(316002)(40480700001)(6666004)(31696002)(82310400005)(83380400001)(235185007)(2906002)(47076005)(6512007)(70586007)(8676002)(33964004)(70206006)(6506007)(336012)(5660300002)(40460700003)(36916002)(186003)(478600001)(2616005)(26005)(8936002)(232243001)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 16:44:17.3082 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 156dcbcf-644c-46eb-1c25-08da70b86995 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6443 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY 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 Earnshaw via Gcc-patches From: "Richard Earnshaw (lists)" Reply-To: Richard Earnshaw 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?1739615593296829937?= X-GMAIL-MSGID: =?utf-8?q?1739615593296829937?= A SET operation that writes memory may have the same value as an earlier store but if the alias sets of the new and earlier store do not conflict then the set is not truly redundant. This can happen, for example, if objects of different types share a stack slot. To fix this we define a new function in cselib that first checks for equality and if that is successful then finds the earlier store in the value history and checks the alias sets. The routine is used in two places elsewhere in the compiler. Firstly in cfgcleanup and secondly in postreload. gcc/ChangeLog: * cselib.h (cselib_redundant_set_p): Declare. * cselib.cc: Include alias.h (cselib_redundant_set_p): New function. * cfgcleanup.cc: (mark_effect): Use cselib_redundant_set_p instead of rtx_equal_for_cselib_p. * postreload.c (reload_cse_simplify): Use cselib_redundant_set_p. (reload_cse_noop_set_p): Delete. diff --git a/gcc/cfgcleanup.cc b/gcc/cfgcleanup.cc index 18047da7b24..a8b0139bb4d 100644 --- a/gcc/cfgcleanup.cc +++ b/gcc/cfgcleanup.cc @@ -208,7 +208,7 @@ mark_effect (rtx exp, regset nonequal) return false; case SET: - if (rtx_equal_for_cselib_p (SET_DEST (exp), SET_SRC (exp))) + if (cselib_redundant_set_p (exp)) return false; dest = SET_DEST (exp); if (dest == pc_rtx) diff --git a/gcc/cselib.cc b/gcc/cselib.cc index 6769beeeaf8..fcfd8340a4a 100644 --- a/gcc/cselib.cc +++ b/gcc/cselib.cc @@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see #include "dumpfile.h" #include "cselib.h" #include "function-abi.h" +#include "alias.h" /* A list of cselib_val structures. */ struct elt_list @@ -1157,6 +1158,75 @@ rtx_equal_for_cselib_1 (rtx x, rtx y, machine_mode memmode, int depth) return 1; } +/* Wrapper for rtx_equal_for_cselib_p to determine whether a SET is + truly redundant, taking into account aliasing information. */ +bool +cselib_redundant_set_p (rtx set) +{ + gcc_assert (GET_CODE (set) == SET); + rtx dest = SET_DEST (set); + if (cselib_reg_set_mode (dest) != GET_MODE (dest)) + return false; + + if (!rtx_equal_for_cselib_p (dest, SET_SRC (set))) + return false; + + while (GET_CODE (dest) == SUBREG + || GET_CODE (dest) == ZERO_EXTRACT + || GET_CODE (dest) == STRICT_LOW_PART) + dest = XEXP (dest, 0); + + if (!flag_strict_aliasing || !MEM_P (dest)) + return true; + + /* For a store we need to check that suppressing it will not change + the effective alias set. */ + rtx dest_addr = XEXP (dest, 0); + + /* Lookup the equivalents to the dest. This is more likely to succeed + than looking up the equivalents to the source (for example, when the + src is some form of constant). */ + cselib_val *src_val = cselib_lookup (SET_DEST (set), + GET_MODE (SET_DEST (set)), + 0, VOIDmode); + + if (src_val) + { + /* Walk the list of source equivalents to find the MEM accessing the same + location. */ + for (elt_loc_list *l = src_val->locs; l; l = l->next) + { + rtx src_equiv = l->loc; + while (GET_CODE (src_equiv) == SUBREG + || GET_CODE (src_equiv) == ZERO_EXTRACT + || GET_CODE (src_equiv) == STRICT_LOW_PART) + src_equiv = XEXP (src_equiv, 0); + + if (MEM_P (src_equiv)) + { + /* Match the MEMs by comparing the addresses. */ + if (rtx_equal_for_cselib_1 (dest_addr, XEXP (src_equiv, 0), + GET_MODE (dest), 0)) + return alias_sets_conflict_p (MEM_ALIAS_SET (dest), + MEM_ALIAS_SET (src_equiv)); + } + } + } + + /* We failed to find a recorded value in the cselib history, so try the + source of this set. */ + rtx src = SET_SRC (set); + while (GET_CODE (src) == SUBREG) + src = XEXP (src, 0); + + if (MEM_P (src) && rtx_equal_for_cselib_1 (dest_addr, XEXP (src, 0), + GET_MODE (dest), 0)) + return alias_sets_conflict_p (MEM_ALIAS_SET (dest), + MEM_ALIAS_SET (src)); + + return false; +} + /* Helper function for cselib_hash_rtx. Arguments like for cselib_hash_rtx, except that it hashes (plus:P x c). */ diff --git a/gcc/cselib.h b/gcc/cselib.h index 9ae65e6459e..b0905053ea5 100644 --- a/gcc/cselib.h +++ b/gcc/cselib.h @@ -83,6 +83,7 @@ extern void cselib_process_insn (rtx_insn *); extern bool fp_setter_insn (rtx_insn *); extern machine_mode cselib_reg_set_mode (const_rtx); extern int rtx_equal_for_cselib_1 (rtx, rtx, machine_mode, int); +extern bool cselib_redundant_set_p (rtx); extern int references_value_p (const_rtx, int); extern rtx cselib_expand_value_rtx (rtx, bitmap, int); typedef rtx (*cselib_expand_callback)(rtx, bitmap, int, void *); diff --git a/gcc/postreload.cc b/gcc/postreload.cc index d1c99fe6dc9..41f61d32648 100644 --- a/gcc/postreload.cc +++ b/gcc/postreload.cc @@ -43,7 +43,6 @@ along with GCC; see the file COPYING3. If not see #include "function-abi.h" #include "rtl-iter.h" -static int reload_cse_noop_set_p (rtx); static bool reload_cse_simplify (rtx_insn *, rtx); static void reload_cse_regs_1 (void); static int reload_cse_simplify_set (rtx, rtx_insn *); @@ -74,16 +73,6 @@ reload_cse_regs (rtx_insn *first ATTRIBUTE_UNUSED) } } -/* See whether a single set SET is a noop. */ -static int -reload_cse_noop_set_p (rtx set) -{ - if (cselib_reg_set_mode (SET_DEST (set)) != GET_MODE (SET_DEST (set))) - return 0; - - return rtx_equal_for_cselib_p (SET_DEST (set), SET_SRC (set)); -} - /* Try to simplify INSN. Return true if the CFG may have changed. */ static bool reload_cse_simplify (rtx_insn *insn, rtx testreg) @@ -118,7 +107,7 @@ reload_cse_simplify (rtx_insn *insn, rtx testreg) this out, so it's safer to simplify before we delete. */ count += reload_cse_simplify_set (body, insn); - if (!count && reload_cse_noop_set_p (body)) + if (!count && cselib_redundant_set_p (body)) { if (check_for_inc_dec (insn)) delete_insn_and_edges (insn); @@ -157,7 +146,7 @@ reload_cse_simplify (rtx_insn *insn, rtx testreg) rtx part = XVECEXP (body, 0, i); if (GET_CODE (part) == SET) { - if (! reload_cse_noop_set_p (part)) + if (! cselib_redundant_set_p (part)) break; if (REG_P (SET_DEST (part)) && REG_FUNCTION_VALUE_P (SET_DEST (part)))