This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/42499] Bad register allocation in multiplication code by constant



------- 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 <get_time>
 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 <get_time>
 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 <sys/time.h>

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]