From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22080 invoked by alias); 13 Oct 2015 13:09:59 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 22037 invoked by uid 48); 13 Oct 2015 13:09:55 -0000 From: "segher at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug inline-asm/67944] GCC emits unnecessary push/pop for callee-save reads. Date: Tue, 13 Oct 2015 13:09:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: inline-asm X-Bugzilla-Version: 5.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: segher 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: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-10/txt/msg01004.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67944 --- Comment #3 from Segher Boessenkool --- Your expectation is not in line with what the compiler actually promises you: the only guarantee is that the local register variable will be in (in your case) ebx _where used in an asm statement_. Other than that, it is just a local variable. You get a save/restore sequence in the prologue and epilogue because ebx is a non-volatile register and this function uses that register. Scheduling later moves the push later in the code. If you want to simply grab what is in ebx, you can use asm, like long reg; asm("mov %%ebx,%0" : "=r"(reg));