public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: rohitgeek <rohit23taneja@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Re: optimization options not working
Date: Mon, 01 Mar 2010 05:09:00 -0000	[thread overview]
Message-ID: <27714100.post@talk.nabble.com> (raw)
Message-ID: <20100301050900.tYMuZ7oGFwLk21sK6gnWx6G-xBwAaphdNC4_ahZWcgc@z> (raw)





I will try to be descriptive this time .

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?

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.


Thanks
   
-- 
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.

         reply	other threads:[~2010-03-01  5:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-18 12:08 rohitgeek
2010-02-18 13:46 ` Andrew Haley
2010-02-19 19:07   ` rohitgeek
2010-02-23 18:19     ` Ian Lance Taylor
2010-02-24  5:21       ` rohitgeek [this message]
2010-02-24 14:11         ` rohitgeek
2010-02-24 18:28         ` Andrew Haley
2010-03-01  5:09         ` rohitgeek
2010-03-01 15:27         ` John S. Fine
2010-03-01 21:21         ` Ian Lance Taylor
2010-03-02  4:57           ` rohitgeek
2010-03-02  8:32             ` Cedric Roux
2010-03-02 12:44               ` rohitgeek
2010-02-24  5:23       ` rohitgeek
2010-02-24  5:23       ` rohitgeek
2010-02-24  5:26       ` rohitgeek
2010-02-24  5:27       ` rohitgeek
2010-02-24  5:32       ` rohitgeek
2010-02-24  9:30         ` rohitgeek
2010-02-24  9:18       ` rohitgeek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=27714100.post@talk.nabble.com \
    --to=rohit23taneja@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).