From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12920 invoked by alias); 13 Jun 2011 12:57:56 -0000 Received: (qmail 12905 invoked by uid 22791); 13 Jun 2011 12:57:55 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_TV,TW_VF X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Jun 2011 12:57:41 +0000 From: "philb at gnu dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/49391] New: [arm] sp not accepted as input for alu operation X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: philb at gnu dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Mon, 13 Jun 2011 12:57:00 -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 X-SW-Source: 2011-06/txt/msg01114.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49391 Summary: [arm] sp not accepted as input for alu operation Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: target AssignedTo: unassigned@gcc.gnu.org ReportedBy: philb@gnu.org Target: arm-linux $ cat t.c #define THREAD_SIZE 8192 static inline struct thread_info *current_thread_info(void) { register unsigned long sp asm ("sp"); return (struct thread_info *)(sp & ~(THREAD_SIZE - 1)); } int f() { return (int)current_thread_info(); } $ arm-linux-gnueabi-gcc -O2 -S t.c $ cat t.s .cpu arm10tdmi .fpu softvfp .eabi_attribute 20, 1 .eabi_attribute 21, 1 .eabi_attribute 23, 3 .eabi_attribute 24, 1 .eabi_attribute 25, 1 .eabi_attribute 26, 2 .eabi_attribute 30, 2 .eabi_attribute 18, 4 .file "t.c" .text .align 2 .global f .type f, %function f: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 @ link register save eliminated. mov r3, sp bic r0, r3, #8128 bic r0, r0, #63 bx lr .size f, .-f .ident "GCC: (GNU) 4.6.0" .section .note.GNU-stack,"",%progbits The "mov r3, sp" is redundant since sp could be used directly as the second operand to BIC. It wasn't immediately obvious to me from the predicates on arm_andsi3_insn why combine wouldn't be accepting sp as an input operand to that pattern, but apparently it isn't. (This particular idiom of calculating from sp is used quite frequently in the Linux kernel.)