From patchwork Sun Apr 23 11:54:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 753908 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w9nwQ6RxJz9s0Z for ; Sun, 23 Apr 2017 21:55:17 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="nawY8tuI"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type:mime-version; q=dns; s= default; b=SjiR6OWYrRqaI2B5IHbD7KcCNXD4j+j3dR36954iseSUBFNO4Mpuc 34qDmcyDU6i8Kcl692H8d9H00A6QhSJW4uRK7MJF7C6+1U1jdh5xFATgkYoWu1hW IdBwBoQ2zRn4ap4+GA3tyr670bXqq4gTrO22CG1do1lPd36OfJy630= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type:mime-version; s= default; bh=ntfMxMjC/tm0/EwDrnIRVYL2ak8=; b=nawY8tuIHeyiyE/AAGkO BdCxTxWa1+xQZG022NlVEMYy/nWCFhagycp0Q+VGp69TPSEHrdSQa1n6mUJy/RhX fRXVJZOY8c/GxW1eF++e/gWQDrJnMAdQa7kV3bRqFVgUX31UXGWEbP6y269SmZUs 5vszBP81R7VED1yQtGxK/Ok= Received: (qmail 62772 invoked by alias); 23 Apr 2017 11:55:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 62731 invoked by uid 89); 23 Apr 2017 11:55:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=Jeff, affairs, H*RU:sk:DB5EUR0, Hx-spam-relays-external:sk:DB5EUR0 X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-oln040092066018.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (40.92.66.18) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 23 Apr 2017 11:55:01 +0000 Received: from DB5EUR01FT048.eop-EUR01.prod.protection.outlook.com (10.152.4.56) by DB5EUR01HT027.eop-EUR01.prod.protection.outlook.com (10.152.5.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1019.14; Sun, 23 Apr 2017 11:55:00 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com (10.152.4.60) by DB5EUR01FT048.mail.protection.outlook.com (10.152.5.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.9 via Frontend Transport; Sun, 23 Apr 2017 11:55:00 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com ([fe80::40a0:2642:4335:50ed]) by AM4PR0701MB2162.eurprd07.prod.outlook.com ([fe80::40a0:2642:4335:50ed%19]) with mapi id 15.01.1061.010; Sun, 23 Apr 2017 11:55:00 +0000 From: Bernd Edlinger To: Jeff Law , "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH][ PR rtl-optimization/79286] Drop may_trap_p exception to testing dominance in update_equiv_regs Date: Sun, 23 Apr 2017 11:54:59 +0000 Message-ID: authentication-results: redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=hotmail.de; x-incomingtopheadermarker: OriginalChecksum:02A8E61A2B2B97CF044AE8322B893D2E9423568A45880DD8B4BD5582FBF6E862; UpperCasedChecksum:80C12498552CA0116B38280E3A8DD9575F8E871223D244C248A4988276CC8C01; SizeAsReceived:7972; Count:37 x-ms-exchange-messagesentrepresentingtype: 1 x-microsoft-exchange-diagnostics: 1; DB5EUR01HT027; 5:4iaVONkvmBTqz699Oi6tFLz4hLO72VOQfg1xxZhTsU1gstCX+4JLoQgi2rV14F5rMBZUqicYzfkLsdUrb7XA1zzMbADbRKbT4bBNXz98tTZwPPYB2fJ4tbQ6QuDLgT0HsBmEdKLAKmYszHZkNJqJHw==; 24:HDmeq5IcxRpI1iTOJSBHf0MqIsK0oHUQsz34MKm2vTAoZNSfpdDzGhV2Z43wgfxsIFBOMo3YLQONeCSeUjdikzg8pIOFrRGbSYTzf+s/eNA=; 7:WVhRJIJLSh2wsZdcJLHcfPmsoqD+YEmEmHDUogco4Vx+OrNwc5xNIat+AFRXADJqBwLtoxwZqMaVWmHkSWTQlLso7/xfIzW2lRad1C77VlBEdQurRCdXht2aInmr8vXbbY4sgXix1dO3wheFxRiwrbUQPxqkRwJFlX0ijJ1R6tY2Wki5p6ihGXBgRRVu/40Bf8RaUM1fmupbA9qTnMYqjESvt1NL8xNPul6IHGrpF3wNzRjwJUQrAw5fX6bxJNJnjeRavuN9YCuAJlFVouRnOL70nDgAkWI+O+rDTQ0lIcvL/CkO9BzpUq47Hw+Jcywc x-incomingheadercount: 37 x-eopattributedmessage: 0 x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(7070007)(98901004); DIR:OUT; SFP:1901; SCL:1; SRVR:DB5EUR01HT027; H:AM4PR0701MB2162.eurprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; x-ms-office365-filtering-correlation-id: 4e0721ec-2836-4da3-67d9-08d48a3f9114 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201702061074)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322274)(1601125374)(1603101448)(1701031045); SRVR:DB5EUR01HT027; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:DB5EUR01HT027; BCL:0; PCL:0; RULEID:; SRVR:DB5EUR01HT027; x-forefront-prvs: 0286D7B531 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Apr 2017 11:54:59.9558 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5EUR01HT027 Hi Jeff, this patch tries to fix the handling of pic_offset_rtx + const(unspec(symbol_ref)+ const_int) in may_trap_p, and restores the original state of affairs in update_equiv_regs. What do you think is it OK to extract the symbol_ref out of the unspec in this way, or is does it need a target hook? Patch works at least for x86_64 and arm. Is it OK for trunk? Bernd. 2017-04-23 Bernd Edlinger rtl-optimizatoin/79286 * ira.c (update_equiv_regs): Revert to using may_tap_p again. * rtlanal.c (rtx_addr_can_trap_p_1): SYMBOL_REF_FUNCTION_P can never trap. Extract constant offset from pic_offset_table_rtx + const(unspec(symbol_ref)+int_val) and pic_offset_table_rtx + const(unspec(symbol_ref)), otherwise RTL may trap. Index: gcc/ira.c =================================================================== --- gcc/ira.c (revision 247077) +++ gcc/ira.c (working copy) @@ -3551,7 +3551,8 @@ update_equiv_regs (void) if (DF_REG_DEF_COUNT (regno) == 1 && note && !rtx_varies_p (XEXP (note, 0), 0) - && def_dominates_uses (regno)) + && (!may_trap_or_fault_p (XEXP (note, 0)) + || def_dominates_uses (regno))) { rtx note_value = XEXP (note, 0); remove_note (insn, note); Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c (revision 247077) +++ gcc/rtlanal.c (working copy) @@ -485,7 +485,7 @@ rtx_addr_can_trap_p_1 (const_rtx x, HOST_WIDE_INT case SYMBOL_REF: if (SYMBOL_REF_WEAK (x)) return 1; - if (!CONSTANT_POOL_ADDRESS_P (x)) + if (!CONSTANT_POOL_ADDRESS_P (x) && !SYMBOL_REF_FUNCTION_P (x)) { tree decl; HOST_WIDE_INT decl_size; @@ -645,8 +645,23 @@ rtx_addr_can_trap_p_1 (const_rtx x, HOST_WIDE_INT case PLUS: /* An address is assumed not to trap if: - it is the pic register plus a constant. */ - if (XEXP (x, 0) == pic_offset_table_rtx && CONSTANT_P (XEXP (x, 1))) - return 0; + if (XEXP (x, 0) == pic_offset_table_rtx + && GET_CODE (XEXP (x, 1)) == CONST) + { + x = XEXP (XEXP (x, 1), 0); + if (GET_CODE (x) == UNSPEC + && GET_CODE (XVECEXP (x, 0, 0)) == SYMBOL_REF) + return rtx_addr_can_trap_p_1(XVECEXP (x, 0, 0), + offset, size, mode, unaligned_mems); + if (GET_CODE (x) == PLUS + && GET_CODE (XEXP (x, 0)) == UNSPEC + && GET_CODE (XVECEXP (XEXP (x, 0), 0, 0)) == SYMBOL_REF + && CONST_INT_P (XEXP (x, 1))) + return rtx_addr_can_trap_p_1(XVECEXP (XEXP (x, 0), 0, 0), + offset + INTVAL (XEXP (x, 1)), + size, mode, unaligned_mems); + return 1; + } /* - or it is an address that can't trap plus a constant integer. */ if (CONST_INT_P (XEXP (x, 1))