Generated Assembly Code Inefficent

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Generated Assembly Code Inefficent

1,105件の閲覧回数
KenH
Contributor II
Hi

I am using Metrowerks v6.4 compiling C code. I looked through the message board for a similar post and did not find one. My apoligies if this has already been discussed. This is for a 5270 micro, optimization level2 (doesn't matter as long as it is not level 0 ). My quesion is: Is there a way to get Metrowerks to generate for example (a0)+ (emphasis on the +) instruciton when imcrementing pointers?

Thank you.


I have this simple code (snippet)

char *ascii_data = cpe.data ;  //(cpe.data is a structure array of 400 chars )

   *ascii_data++  = '0' ;  // Group
   *ascii_data++  = '1' ;  // Duration
   *ascii_data++  = '1' ;  // default on pattern
   *ascii_data++  = '1' ;  // default of pattern

I would expect something like this generated

move.b d1, (a0)+
move.b d0, (a0)+
move.b d0, (a0)+
move.b d0, (a0)+



I get this:

  779:    *ascii_data++  = '0' ;  // Group
;
0x000001B6  0x204E                   movea.l  a6,a0
0x000001B8  0x528E                   addq.l   #1,a6
0x000001BA  0x1081                   move.b   d1,(a0)
;
;  780:    *ascii_data++  = '1' ;  // Duration
;
0x000001BC  0x204E                   movea.l  a6,a0
0x000001BE  0x528E                   addq.l   #1,a6
0x000001C0  0x1080                   move.b   d0,(a0)
;
;  781:    *ascii_data++  = '1' ;  // default on pattern
;
0x000001C2  0x204E                   movea.l  a6,a0
0x000001C4  0x528E                   addq.l   #1,a6
0x000001C6  0x1080                   move.b   d0,(a0)
;
;

====================



ラベル(1)
0 件の賞賛
1 返信

394件の閲覧回数
CompilerGuru
NXP Employee
NXP Employee
When I remember right there was once a thread where coding the post increment as separate statement did help, but that was for a loop and not for multiple assignments.

With this code I get that (with CF 6.3, not 6.4).


Code:
extern char array[];#pragma opt_propagation offvoid function(){    char *  ascii_data= array;    *ascii_data  = '0' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;    *ascii_data  = '1' ; ascii_data++;}

 

That generates
Code:
0x00000000                    _function:;                             function:0x00000000  0x41F900000000           lea      _array,a00x00000006  0x10FC0030               move.b   #48,(a0)+             ; '0'0x0000000A  0x7031                   moveq    #49,d00x0000000C  0x10C0                   move.b   d0,(a0)+0x0000000E  0x10C0                   move.b   d0,(a0)+0x00000010  0x10C0                   move.b   d0,(a0)+0x00000012  0x10C0                   move.b   d0,(a0)+0x00000014  0x10C0                   move.b   d0,(a0)+0x00000016  0x10C0                   move.b   d0,(a0)+0x00000018  0x10C0                   move.b   d0,(a0)+0x0000001A  0x10C0                   move.b   d0,(a0)+0x0000001C  0x10C0                   move.b   d0,(a0)+0x0000001E  0x10C0                   move.b   d0,(a0)+0x00000020  0x10C0                   move.b   d0,(a0)+0x00000022  0x10C0                   move.b   d0,(a0)+0x00000024  0x1080                   move.b   d0,(a0)0x00000026  0x11400001               move.b   d0,1(a0)0x0000002A  0x4E75                   rts     

 

0 件の賞賛