From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 174AD385842A; Mon, 25 Oct 2021 14:46:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 174AD385842A From: "ardb at kernel dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/102926] TLS register value is spilled to the stack instead of reloaded from the system register Date: Mon, 25 Oct 2021 14:46:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: ardb at kernel dot 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: Message-ID: In-Reply-To: References: 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, 25 Oct 2021 14:46:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102926 --- Comment #5 from Ard Biesheuvel --- Actually, I can reproduce the same behavior without the TLS register, where= the result of a MOVW/MOVT immediate assignment is also spilled to the stack. int ll[2]; int foo(int); int bar(void) { int *l =3D ll; return foo(l[0]) + l[1]; } will produce this for armv7-a (with [r4-r11] fixed) push {fp, lr} movw r3, #:lower16:.LANCHOR0 movt r3, #:upper16:.LANCHOR0 add fp, sp, #4 sub sp, sp, #8 ldr r0, [r3] str r3, [fp, #-8] bl foo ldr r3, [fp, #-8] ldr r3, [r3, #4] add r0, r0, r3 sub sp, fp, #4 @ sp needed pop {fp, pc} whereas pre-v7 gives me ldr r3, .L4 push {fp, lr} add fp, sp, #4 ldr r0, [r3] bl foo ldr r3, .L4 ldr r3, [r3, #4] add r0, r0, r3 pop {fp, pc} i.e., the address is simply reloaded from the literal pool rather than spil= led.=