Ian Lance Taylor-3 wrote: > > rohitgeek <rohit23taneja@xxxxxxxxx> writes: > >> 1. Created the machine description files >> 2. Build my target (successful) >> 3. Compile >> Now this step works correctly i.e. generate correct assembly if i >> do >> not put any optimization option. >> >> command : ---- ./target-gcc -S test.c -> works >> ./target-gcc -O1/2/3 -S test.c -> no >> assembly corresponding to the variable assignment and all other >> operations >> i.e. it generates only prologue and epilogue(if i am correct for later >> part). > > You didn't show us test.c. You have to tell us what you did if you > expect a good answer to your question. > > Without seeing test.c, I would guess that the variables are not used, > and were removed by the optimizers. > > >> Give me some insight into working of peephole optimizations, how do i >> start >> doing that. > > Peephole optimization is a specific type of optimization. See > define_peephole and define_peephole2 in the internals documentation. > See many examples in the existing backends. > > > Ian > > 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.