From patchwork Fri May 15 10:35:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Coplan X-Patchwork-Id: 1291015 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=frlbJyjA; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=frlbJyjA; dkim-atps=neutral Received: from sourceware.org (server2.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 49NlFL6N7Fz9sTc for ; Fri, 15 May 2020 20:36:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 00147397CF31; Fri, 15 May 2020 10:36:18 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00046.outbound.protection.outlook.com [40.107.0.46]) by sourceware.org (Postfix) with ESMTPS id BE6DE397CF0B for ; Fri, 15 May 2020 10:36:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BE6DE397CF0B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Alex.Coplan@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7+HGFdAYzObl1JfWe0wunj0tfOt61JSPLPprgD2/rYM=; b=frlbJyjATn0DlMXCe3zzYG5C2lnM0HjMCOO5DbSSYE3XDhzRtimixRZsUF7ktEEgMTpza45qz1qE7tfAVIJbmGO7HEY3Q/u2r8J6iLFjTYvB9YQz7xqNA/xDtYN2JL9O1HqloA51Z+xAFa7lgH3Ltw/AyzH0o7RqUsirmahCtho= Received: from AM7PR04CA0024.eurprd04.prod.outlook.com (2603:10a6:20b:110::34) by VI1PR08MB5373.eurprd08.prod.outlook.com (2603:10a6:803:131::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.24; Fri, 15 May 2020 10:36:05 +0000 Received: from AM5EUR03FT062.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:110:cafe::cf) by AM7PR04CA0024.outlook.office365.com (2603:10a6:20b:110::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.25 via Frontend Transport; Fri, 15 May 2020 10:36:04 +0000 Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;gcc.gnu.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT062.mail.protection.outlook.com (10.152.17.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.19 via Frontend Transport; Fri, 15 May 2020 10:36:03 +0000 Received: ("Tessian outbound fb9de21a7e90:v54"); Fri, 15 May 2020 10:36:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: bd99add21612562b X-CR-MTA-TID: 64aa7808 Received: from ce243f43f7d4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C04CEC58-D785-4AA3-8771-884C2E0F1530.1; Fri, 15 May 2020 10:35:58 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ce243f43f7d4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 15 May 2020 10:35:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VB6W+Yr5XaFCZ2uVU5ij1pYU6c1+bZrq0hZGLd4LSaGhF/pK/lf7jZQCOWAFmIflKuIAZ6QL93/kJ7UOXGxW3eIVzEm0NAp8kC+TKdULf9JWlbl8S/z8TdoueXWnkpZzaZh7whh0WK3gwhrS/XHQanqwCPsvAbt/Lz1XwusV19b8f6CTdluJhjSqZyftJlgVOBReYhZAmnIEGiCSOgQQUvg/oJbnsEoLxnvG/he07deR2BlXrQ23i25YsqwikXxgoegYqTSpKQL/Lvj8jPtDHwrormf77+AhkS6xoHSoCx5g1gx2xYGU2kXR5vX06Vn61yUyqoMiu6A5zmLU3n7+ZQ== 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-SenderADCheck; bh=7+HGFdAYzObl1JfWe0wunj0tfOt61JSPLPprgD2/rYM=; b=MEiTqTzYttJBOpD9YcZVAlI82GKstW/3r+AduxR89FB/1ZXgLQddac0bsslyfinohKwzmW1eoQ5yujxR+ds/gwHlUqpjfJPCsd6i67x7IxIX07S/e1LMAUyNn4c4GSOvDiWhFKQyHLBH84z7w8K/CCk2O4tuEOAWOqt+RCh/qoQDBxMqBS5kQ4CH7ZIAoGYrWRmAsJ681sPS85oeICVgm21HhkD1b+AANf8wfiHtLNiNoQ9pct5rLFIkCgrWlExLCrrHcDe78EE61nYWsIB5NgqvzkXCAULxS/SUjUN0PAT6L4+CPiF6QCHJHWHrRLRsdWUDB5XupNJ+4ZwjbS5ykQ== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7+HGFdAYzObl1JfWe0wunj0tfOt61JSPLPprgD2/rYM=; b=frlbJyjATn0DlMXCe3zzYG5C2lnM0HjMCOO5DbSSYE3XDhzRtimixRZsUF7ktEEgMTpza45qz1qE7tfAVIJbmGO7HEY3Q/u2r8J6iLFjTYvB9YQz7xqNA/xDtYN2JL9O1HqloA51Z+xAFa7lgH3Ltw/AyzH0o7RqUsirmahCtho= Received: from VI1PR08MB4029.eurprd08.prod.outlook.com (2603:10a6:803:ec::14) by VI1PR08MB4495.eurprd08.prod.outlook.com (2603:10a6:803:f3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.30; Fri, 15 May 2020 10:35:56 +0000 Received: from VI1PR08MB4029.eurprd08.prod.outlook.com ([fe80::88b4:476f:5960:5ae4]) by VI1PR08MB4029.eurprd08.prod.outlook.com ([fe80::88b4:476f:5960:5ae4%6]) with mapi id 15.20.2979.033; Fri, 15 May 2020 10:35:56 +0000 From: Alex Coplan To: "gcc-patches@gcc.gnu.org" Subject: [PATCH] [arm] Don't generate invalid LDRD insns Thread-Topic: [PATCH] [arm] Don't generate invalid LDRD insns Thread-Index: AdYqo7NIZ96BKXJ6ToKpLmliva4LiA== Date: Fri, 15 May 2020 10:35:56 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Authentication-Results-Original: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; x-originating-ip: [217.140.99.251] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 333ed52e-5eca-4388-93a6-08d7f8bbc4c7 x-ms-traffictypediagnostic: VI1PR08MB4495:|VI1PR08MB4495:|VI1PR08MB5373: x-ld-processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:3826;OLM:3826; x-forefront-prvs: 04041A2886 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: RSTxRk5UctL2nCunyc6uP0k97k98C4DrjDrTy8Y41EE470oLWuL4KAATe73hwVKmSeDlPHULPOItQFa8sBAqEJnMirdcJJgyxRDOJcfAAXLr2RCcBim/9PrkpKoiNz0NP6uo1b4PL+EEjY9IeY4UvIxye9B4cW5D9g7sJjBzawTbXs44Nz85rztAyMuC4S5joceGFXLNXWV5Etzf0tayqtEK2mOqSObaZ+XqwuL1NWdhJtoSWgFuI8zlHhBBuNtEg13Rx2dOt33jTbX2Oh1sAzrJhukel8UOPm2rn7aFy9M/t7wDwf3HFv4AHPGWENkUGX8BW6TIN/xTEbL4zjUiCtywaQWe15quQhG9UKidV2CSnoei6pUIMMPqQdZJx+UjG8tgy0OCIxJwl243GPMd9CdXCVa1B4bKhoPCtAKnJZ1cfOyzkenFhEefOBgNnLM+dcfSOmxdhb1SKhPATJgAm2gFt+mx1HDYjzRSLwKPLOSVJmKN6Dk537E2P8iH4S0RDRNhP1yoXi0DJ4bRRWUwpQ== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB4029.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(366004)(376002)(39860400002)(346002)(136003)(5660300002)(6506007)(76116006)(26005)(66556008)(7696005)(33656002)(4326008)(316002)(66476007)(8676002)(66946007)(64756008)(66446008)(2906002)(86362001)(71200400001)(55016002)(966005)(66616009)(52536014)(6916009)(99936003)(54906003)(478600001)(9686003)(8936002)(186003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: gTE7262vai1tH4rgsQYO1u0Ji5mtenwQXPfGHzllfg3vua7efYdT/885nH0YpzjkBBGnBKAL/Yxd9wZyEH2+WVJFeef2ZxB+11Muc7HLeDasmbxCX0SQhlGP3CfqzGIViSWIkUVg/DUaNhWtE0434U2OsQW+kDbN3GpeWXwvDIKYVJeNo6AfMGtogCleGp982CUmo4h0JucaGWN7lvEH0PGZwvGqneQ2/EYgNV+ku4pWaXWa3emqu9I7xXU5CDjAICl5sKJmNitoLE6O6nHV/ctcd+AH8U0bXWWG61/4Kq9rpv6nm7FHVH443AOHHCCiqr3iOTyHerVAOxaPIJ7DvPUeldLyR/GyQ4pxYWhWr1ghPYNGzlGKsDN4PICv5Ed4Y7wIk/aSDpwmXnoXZXHxDcY8jbDEVvrgW0OCay8ORgiGsAUtRpnsMeL8+sUOAy0AoIF6hyDrtMtPCRoi9S/KDaK8BiPXjTTOo5qYEHhVFJJM5pNqAR9kGsSXZw0KqroJ MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4495 Original-Authentication-Results: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT062.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(376002)(346002)(396003)(136003)(39860400002)(46966005)(7696005)(33656002)(336012)(6506007)(52536014)(70586007)(70206006)(8936002)(186003)(8676002)(478600001)(966005)(55016002)(66616009)(9686003)(86362001)(26005)(82740400003)(4326008)(47076004)(2906002)(6916009)(36906005)(21480400003)(81166007)(356005)(99936003)(235185007)(54906003)(82310400002)(316002)(5660300002); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: a3dea8af-0013-43dc-2809-08d7f8bbc067 X-Forefront-PRVS: 04041A2886 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tmAr7c5WbCChpTJTom0lmesdqdYgmVF4BrC2LdiBQkSSOweThEZUeKy2s4UyXj8rj1o+Zaq0yFknNH43G12WcO8bJ4z9wBi9Yx1sLnF4z1FW3XFhRe/+dWMjVWw8qC5yuJ1U17n7IvJFmZX2KWujBuciY7MiX0HCMS7/c/FjD9nLGL2og/eAGTgsK7wGP0TWBy3B1UujweOu+LglrFoPkPndtbl1WYYOhmrgQGWLmowwyMzOMStb8T+Fcbe6BKwPC78NidC0FkLW0wzuAtIyL+0TslJxla1NRqAyN57puXxPpwCRRws9APcpv23TUq2bMxw0Bop4fnmbxr1cXkHMAEq9P2tnOyndBFkfd/NWdFrP2QV4Q1kiWDONiPY7Qg7TpdBYLB36gceXAf9OE6ZVHtGX9gNnAegZZFccRoimBqU2GsGET/ekTkzVC4hLsslkhoNrS98m99L1c3aMsFdJGmzHlcgFwveXUYduWD3dVMGif7NSSvVVzkUkWBfyi7LCES2t6GJiOX05b4rQPaB0SVaODvSC63eTFOk5EQe+vFQZLUKqOmvH8CR+J0yTcGTzVsIxw7XksJDLzu29VJyAQQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2020 10:36:03.9421 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 333ed52e-5eca-4388-93a6-08d7f8bbc4c7 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5373 X-Spam-Status: No, score=-20.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Richard Earnshaw , nd , Ramana Radhakrishnan Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hello, This patch fixes a bug in the arm backend where GCC generates invalid LDRD instructions. The LDRD instruction requires the first transfer register to be even, but GCC attempts to use odd registers here. For example, with the following C code: struct c { double a; } __attribute((aligned)) __attribute((packed)); struct c d; struct c f(struct c); void e() { f(d); } The struct d is passed in registers r1 and r2 to the function f, and GCC attempts to do this with a LDRD instruction when compiling with -march=armv7-a on a soft float toolchain. The fix is analogous to the corresponding one for STRD in the same function: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=52057dc4ac5295caebf83147f688d769c93cbc8d Testing: - New unit tests which pass after applying the patch. - Tested on an x64 -> arm-none-eabi cross. - Bootstrapped and regtested on arm-none-linux-gnueabihf (in both thumb and arm modes). OK for master? Thanks, Alex --- gcc/ChangeLog: 2020-05-15 Alex Coplan * config/arm/arm.c (output_move_double): Fix codegen when loading into a register pair with an odd base register. gcc/testsuite/ChangeLog: 2020-05-15 Alex Coplan * gcc.c-torture/compile/packed-aligned-1.c: New test. * gcc.c-torture/execute/packed-aligned.c: New test. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index d50781953c0..0ac1961696e 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -19551,6 +19551,7 @@ output_move_double (rtx *operands, bool emit, int *count) if (code0 == REG) { unsigned int reg0 = REGNO (operands[0]); + const bool can_ldrd = TARGET_LDRD && (TARGET_THUMB2 || (reg0 % 2 == 0)); otherops[0] = gen_rtx_REG (SImode, 1 + reg0); @@ -19562,7 +19563,7 @@ output_move_double (rtx *operands, bool emit, int *count) if (emit) { - if (TARGET_LDRD + if (can_ldrd && !(fix_cm3_ldrd && reg0 == REGNO(XEXP (operands[1], 0)))) output_asm_insn ("ldrd%?\t%0, [%m1]", operands); else @@ -19571,7 +19572,7 @@ output_move_double (rtx *operands, bool emit, int *count) break; case PRE_INC: - gcc_assert (TARGET_LDRD); + gcc_assert (can_ldrd); if (emit) output_asm_insn ("ldrd%?\t%0, [%m1, #8]!", operands); break; @@ -19579,7 +19580,7 @@ output_move_double (rtx *operands, bool emit, int *count) case PRE_DEC: if (emit) { - if (TARGET_LDRD) + if (can_ldrd) output_asm_insn ("ldrd%?\t%0, [%m1, #-8]!", operands); else output_asm_insn ("ldmdb%?\t%m1!, %M0", operands); @@ -19589,7 +19590,7 @@ output_move_double (rtx *operands, bool emit, int *count) case POST_INC: if (emit) { - if (TARGET_LDRD) + if (can_ldrd) output_asm_insn ("ldrd%?\t%0, [%m1], #8", operands); else output_asm_insn ("ldmia%?\t%m1!, %M0", operands); @@ -19597,7 +19598,7 @@ output_move_double (rtx *operands, bool emit, int *count) break; case POST_DEC: - gcc_assert (TARGET_LDRD); + gcc_assert (can_ldrd); if (emit) output_asm_insn ("ldrd%?\t%0, [%m1], #-8", operands); break; @@ -19619,6 +19620,7 @@ output_move_double (rtx *operands, bool emit, int *count) /* Registers overlap so split out the increment. */ if (emit) { + gcc_assert (can_ldrd); output_asm_insn ("add%?\t%1, %1, %2", otherops); output_asm_insn ("ldrd%?\t%0, [%1] @split", otherops); } @@ -19630,10 +19632,11 @@ output_move_double (rtx *operands, bool emit, int *count) /* Use a single insn if we can. FIXME: IWMMXT allows offsets larger than ldrd can handle, fix these up with a pair of ldr. */ - if (TARGET_THUMB2 + if (can_ldrd + && (TARGET_THUMB2 || !CONST_INT_P (otherops[2]) || (INTVAL (otherops[2]) > -256 - && INTVAL (otherops[2]) < 256)) + && INTVAL (otherops[2]) < 256))) { if (emit) output_asm_insn ("ldrd%?\t%0, [%1, %2]!", otherops); @@ -19656,10 +19659,11 @@ output_move_double (rtx *operands, bool emit, int *count) /* Use a single insn if we can. FIXME: IWMMXT allows offsets larger than ldrd can handle, fix these up with a pair of ldr. */ - if (TARGET_THUMB2 + if (can_ldrd + && (TARGET_THUMB2 || !CONST_INT_P (otherops[2]) || (INTVAL (otherops[2]) > -256 - && INTVAL (otherops[2]) < 256)) + && INTVAL (otherops[2]) < 256))) { if (emit) output_asm_insn ("ldrd%?\t%0, [%1], %2", otherops); @@ -19690,7 +19694,7 @@ output_move_double (rtx *operands, bool emit, int *count) operands[1] = otherops[0]; if (emit) { - if (TARGET_LDRD) + if (can_ldrd) output_asm_insn ("ldrd%?\t%0, [%1]", operands); else output_asm_insn ("ldmia%?\t%1, %M0", operands); @@ -19735,7 +19739,7 @@ output_move_double (rtx *operands, bool emit, int *count) } otherops[0] = gen_rtx_REG(SImode, REGNO(operands[0]) + 1); operands[1] = otherops[0]; - if (TARGET_LDRD + if (can_ldrd && (REG_P (otherops[2]) || TARGET_THUMB2 || (CONST_INT_P (otherops[2]) @@ -19796,7 +19800,7 @@ output_move_double (rtx *operands, bool emit, int *count) if (count) *count = 2; - if (TARGET_LDRD) + if (can_ldrd) return "ldrd%?\t%0, [%1]"; return "ldmia%?\t%1, %M0"; diff --git a/gcc/testsuite/gcc.c-torture/compile/packed-aligned-1.c b/gcc/testsuite/gcc.c-torture/compile/packed-aligned-1.c new file mode 100644 index 00000000000..9f0923e29ee --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/packed-aligned-1.c @@ -0,0 +1,11 @@ +struct c { + double a; +} __attribute((packed)) __attribute((aligned)); + +void f(struct c *, struct c); + +void g(struct c *ptr) +{ + ptr++; + f(ptr, *ptr); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/packed-aligned.c b/gcc/testsuite/gcc.c-torture/execute/packed-aligned.c new file mode 100644 index 00000000000..f768af0ab02 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/packed-aligned.c @@ -0,0 +1,28 @@ +struct c { + double a; +} __attribute((packed)) __attribute((aligned)); + +extern void abort(void); + +double g_expect = 32.25; + +void f(unsigned x, struct c y) +{ + if (x != 0) + abort(); + + if (y.a != g_expect) + abort(); +} + +struct c e = { 64.25 }; + +int main(void) +{ + struct c d = { 32.25 }; + f(0, d); + + g_expect = 64.25; + f(0, e); + return 0; +}