From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 12A903857C64; Mon, 24 Aug 2020 13:30:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12A903857C64 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598275843; bh=eQNCV1VpUV3ngWOgdPBU8R32t8GZdOMUcDZv7kEZ9vI=; h=From:To:Subject:Date:From; b=BtZSXPoJd5wXEWB8EqasNV+af1Q4FibqZz2ZNGYzaloh9OQdETqSafZHdv2ysB5J7 HT9aVgc6fUdk7522xnR5D1PUccNxUUqpxVx5LlSOrBvjprR7b+p3MSm1jtfvgIy/J+ e23tFO/cemsmrF4b1jWIx2vY0/Tx7p44M4uZBXeQ= From: "clyon at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/96770] New: -mpure-code produces suboptimal code for relocations with small offset for thumb-1 Date: Mon, 24 Aug 2020 13:30:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: clyon at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2020 13:30:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96770 Bug ID: 96770 Summary: -mpure-code produces suboptimal code for relocations with small offset for thumb-1 Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: clyon at gcc dot gnu.org Target Milestone: --- As discussed in PR94538, -mpure-code produces suboptimal code for relocatio= ns with small offset for thumb-1. int arr[10]; int *f4 (void) { return &arr[1]; } Compiled with -O2 -mpure-code, -mcpu=3Dcortex-m0: f4: movs r3, #:upper8_15:#.LC0 lsls r3, #8 adds r3, #:upper0_7:#.LC0 lsls r3, #8 adds r3, #:lower8_15:#.LC0 lsls r3, #8 adds r3, #:lower0_7:#.LC0 @ sp needed ldr r0, [r3] adds r0, r0, #4 bx lr We should avoid the extra load from the literal pool (related to PR96767), = and the 'adds r0,r0,4'. -mcpu=3Dcortex-m23: f4: movw r0, #:lower16:.LANCHOR0 @ sp needed movt r0, #:upper16:.LANCHOR0 adds r0, r0, #4 bx lr For reference, -mcpu=3Dcortex-m3 produces: f4: movw r0, #:lower16:.LANCHOR0+4 movt r0, #:upper16:.LANCHOR0+4 bx lr We should generate the same code for cortex-m23.=