From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107945 invoked by alias); 20 Jul 2017 14:49:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 107839 invoked by uid 89); 20 Jul 2017 14:49:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com Received: from mail-db5eur01on0084.outbound.protection.outlook.com (HELO EUR01-DB5-obe.outbound.protection.outlook.com) (104.47.2.84) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Jul 2017 14:49:13 +0000 Received: from AM5PR0802MB2610.eurprd08.prod.outlook.com (10.175.46.18) by AM5PR0802MB2611.eurprd08.prod.outlook.com (10.175.46.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1282.10; Thu, 20 Jul 2017 14:49:10 +0000 Received: from AM5PR0802MB2610.eurprd08.prod.outlook.com ([fe80::b567:13a:e52:92de]) by AM5PR0802MB2610.eurprd08.prod.outlook.com ([fe80::b567:13a:e52:92de%17]) with mapi id 15.01.1282.011; Thu, 20 Jul 2017 14:49:10 +0000 From: Wilco Dijkstra To: GCC Patches CC: nd Subject: [PATCH] Fix PR46932: Block auto increment on frame pointer Date: Thu, 20 Jul 2017 14:49:00 -0000 Message-ID: authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM5PR0802MB2611;7:FzOq4MbjnjoCAksAtXIgJDRrr5Q60vXXJrH1gscthKKfxylqdPGVtJn3S5zV/qwjmvhoDpSnf2rS4ip5HAevvuqwgTWYhBVlKQ1CtMKRqggYeiZwI22L7cnokKSIXF6mBC6/Hh5PoZz9ysRkqcLYTsWlB5kMXqf2gwCXNWy770ew0Xd1KyXs8+/IoupmmEx+6vhdaxTMJnk7raKyU0kynWj4Q4JqHhkjC0euvLJbyXEBlalKRoZhkFame9xKGeFtoW1BIMZmmjxbnc66RlXrCwgaI6AABdfdLfRnhx/WqBDfAT9zvSpLVrYO88+GPJuao8cYUocSTcrOLBOCYiA2LYGaluTtVNPXxhcjFvvBnxGkTOFZjLHB9J1cikjm8nJue2/pOqyb1b8sTzbYpJ2XPHJ4widKpCnJ1wHHsEjLCtcko2Yyn23qxsZQTiUQzSFXLfznLj4mZLErchGsvXGu/50X+Bk+dDCRufMmIO2ebiidWwkka5YfPOPR6xl22xj1YmFsICVhrd0B2a0NLzzb798AMA8RKnUVseK0CnhK33NdmlcoDEhHtrHSoNNjBMW779mQc1eIB1M+yyIEA7FlIcQzPtcmUd5j7IOQo/UT4eXGbsSHND6yIwYatpQ/EfLhZvVYTZioaVGCakbiHvs5JllECe8mO2CNkJ/Ufg+vXKdfKFJ/OwUJUpfRucFHCUHPhAGHNsERPQeWWZeNI+eoD7i/v6Z8pBFTD9b1En/oXn1hEjKH2ybpoCjXppPtBtGa8ag2hjVj9ZaGoFr8Fs8c0DbRzjOs1rYkKbTGT16hHp4= x-ms-office365-filtering-correlation-id: 4b7a5a71-aabd-4bbb-40c5-08d4cf7e7b00 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(300000503095)(300135400095)(48565401081)(2017052603031)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:AM5PR0802MB2611; x-ms-traffictypediagnostic: AM5PR0802MB2611: nodisclaimer: True x-exchange-antispam-report-test: UriScan:(180628864354917)(236129657087228)(148574349560750)(50300203121483); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(2017060910075)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123558100)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AM5PR0802MB2611;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AM5PR0802MB2611; x-forefront-prvs: 0374433C81 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39400400002)(39840400002)(39450400003)(39410400002)(39850400002)(39860400002)(377424004)(81166006)(5660300001)(14454004)(99286003)(72206003)(5250100002)(3280700002)(3660700001)(55016002)(2906002)(33656002)(4326008)(6916009)(9686003)(25786009)(6436002)(478600001)(6506006)(53936002)(2900100001)(110136004)(38730400002)(74316002)(86362001)(50986999)(8936002)(66066001)(3846002)(189998001)(575784001)(54356999)(8676002)(7736002)(305945005)(7696004)(102836003)(6116002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0802MB2611;H:AM5PR0802MB2610.eurprd08.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jul 2017 14:49:10.1925 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2611 X-SW-Source: 2017-07/txt/msg01245.txt.bz2 Block auto increment on frame pointer references. This is never beneficial since the SFP expands into SP+C or FP+C during register allocation. The generated code for the testcase is now as expected: str x30, [sp, -32]! strb w0, [sp, 31] add x0, sp, 31 bl foo3 ldr x30, [sp], 32 ret On SPEC2017 codesize improves uniformly across the board. ChangeLog: 2017-07-20 Wilco Dijkstra PR middle-end/46932 * auto-inc-dec.c (parse_add_or_inc): Block autoinc on sfp. gcc/testsuite/ * gcc.dg/pr46932.c: New testcase. -- diff --git a/gcc/auto-inc-dec.c b/gcc/auto-inc-dec.c index 91fa5cf0bbe04b8a2c2c2b9209d245a327de0ffd..db1bd5bba2cee9fbf24d6d52250= 5ac292688aab9 100644 --- a/gcc/auto-inc-dec.c +++ b/gcc/auto-inc-dec.c @@ -769,6 +769,12 @@ parse_add_or_inc (rtx_insn *insn, bool before_mem) inc_insn.pat =3D pat; inc_insn.reg_res =3D SET_DEST (pat); inc_insn.reg0 =3D XEXP (SET_SRC (pat), 0); + + /* Block any auto increment of the frame pointer since it expands into + an addition and cannot be removed by copy propagation. */ + if (inc_insn.reg0 =3D=3D frame_pointer_rtx) + return false; + if (rtx_equal_p (inc_insn.reg_res, inc_insn.reg0)) inc_insn.form =3D before_mem ? FORM_PRE_INC : FORM_POST_INC; else diff --git a/gcc/testsuite/gcc.dg/pr46932.c b/gcc/testsuite/gcc.dg/pr46932.c new file mode 100644 index 0000000000000000000000000000000000000000..b96febcc095fbec2cc4e02d1155= 871220d17cc99 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr46932.c @@ -0,0 +1,13 @@ +/* { dg-options "-O2 -fdump-rtl-auto_inc_dec" } */ + +/* Check that accesses based on the frame pointer do not + use auto increment. */ + +extern void foo (char*); +void t01 (char t) +{ + char c =3D t; + foo (&c); +} + +/* { dg-final { scan-rtl-dump-not "success" "auto_inc_dec" } } */