optimization options not working

rohitgeek rohit23taneja@gmail.com
Wed Feb 24 14:11:00 GMT 2010

I will try to be descriptive this time .

This is test.c

  int a,b,c;
   a= 5;
  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

        .file   "test1234.c"
        .align  2
        .global main
        .type   main, %function
        @ 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"
        .align  2
        .global main
        .type   main, %function
        @ 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?

Also bringing into notice the point of single instruction generation instead
of 2 instructions (multiply and accumulate), what part of gcc will do it and
how to proceed regarding that.

View this message in context: http://old.nabble.com/optimization-options-not-working-tp27637400p27714100.html
Sent from the gcc - Help mailing list archive at Nabble.com.

More information about the Gcc-help mailing list