From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19480 invoked by alias); 7 Jan 2010 12:55:38 -0000 Received: (qmail 19428 invoked by uid 48); 7 Jan 2010 12:55:25 -0000 Date: Thu, 07 Jan 2010 12:55:00 -0000 Message-ID: <20100107125525.19427.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug rtl-optimization/42499] Bad register allocation in multiplication code by constant In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "sliao at google dot com" 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: 2010-01/txt/msg00764.txt.bz2 ------- Comment #4 from sliao at google dot com 2010-01-07 12:55 ------- Compilation flags: -march=armv5te -mthumb -Os gcc.4.2.1: (code size 0x1e bytes) push {r4, lr} sub sp, #8 adds r4, r0, #0 mov r0, sp bl 0 ldr r2, [sp, #0] add sp, #8 lsls r3, r2, #2 adds r3, r3, r2 lsls r3, r3, #1 str r3, [r4, #0] asrs r3, r3, #31 str r3, [r4, #4] pop {r4, pc} nop ; (mov r8, r8) // why is this NOP not optimized away? gcc.4.5.0: (code size 0x1c bytes) push {r4, lr} sub sp, #8 adds r4, r0, #0 mov r0, sp bl 0 ldr r3, [sp, #0] add sp, #8 lsls r2, r3, #2 adds r3, r2, r3 lsls r3, r3, #1 str r3, [r4, #0] asrs r3, r3, #31 str r3, [r4, #4] pop {r4, pc} BTW, again, the input program is now #include extern void get_time(struct timeval*); void test(long long *res) { struct timeval tv; get_time(&tv); *res = tv.tv_sec * 10; } 1. I apologize for the confusion on the source code. Originally I used less simplified code from Dalvik_java_lang_System_currentTimeMillis. Now I use this code above, so the code looks different. 2. Anyway, the codes generated by GCC 4.2.1 and 4.5.0 are generally the same (except that there's NOP at the end of the 4.2.1's). I think this bug is resolved in the trunk. -- sliao at google dot com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |RESOLVED Resolution| |FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42499