On 02/24/2010 05:19 AM, rohitgeek wrote: > > > This is test.c > > main() > { > int a,b,c; > a= 5; > b=10; > d=30; > c= a*b + 30 ; > } > > now , suppose i build gcc for an ARM processor. > After build, compile stage --- > > with no optimization options as mentioned above, this is what i get in > assembly. > > .file "test1234.c" > .text > .align 2 > .global main > .type main, %function > main: > @ args = 0, pretend = 0, frame = 16 > @ frame_needed = 1, uses_anonymous_args = 0 > mov ip, sp > stmfd sp!, {fp, ip, lr, pc} > sub fp, ip, #4 > sub sp, sp, #16 > mov r3, #5 > str r3, [fp, #-28] > mov r3, #10 > str r3, [fp, #-24] > mov r3, #30 > str r3, [fp, #-16] > ldr r2, [fp, #-28] > ldr r3, [fp, #-24] > mul r1, r3, r2 > mov r3, r1 > mov r2, r3, asl #2 > mov r3, r2, asl #5 > rsb r3, r2, r3 > add r3, r3, r1 > mov r2, r3, asl #2 > add r3, r3, r2 > mov r3, r3, asl #4 > add r3, r3, #299008 > add r3, r3, #992 > str r3, [fp, #-20] > sub sp, fp, #12 > ldmfd sp, {fp, sp, pc} > .size main, .-main > > > with optimization option turned on (mentioned in command line) > > assembly :- > > .file "test1234.c" > .text > .align 2 > .global main > .type main, %function > main: > @ args = 0, pretend = 0, frame = 0 > @ frame_needed = 0, uses_anonymous_args = 0 > @ link register save eliminated. > bx lr > .size main, .-main > > > Did i missed something during building time? No. It looks to me like the optimizer is working really well. The function doesn't do anything, so gcc has optimized away all its statmements. Andrew.