This sounds like a dumb question I know. However the following code
snippet results in many more machine instructions under 4.4.2 than under
2.9.5 (I am running a cygwin->PowerPC cross):
typedef unsigned int U32;
typedef union
{
U32 R;
struct
{
U32 BF1:2;
U32 :8;
U32 BF2:2;
U32 BF3:2;
U32 :18;
} B;
} TEST_t;
U32 testFunc(void)
{
TEST_t t;
t.R=0;
t.B.BF1=2;
t.B.BF2=3;
t.B.BF3=1;
return t.R;
}
Output under 4.4.2 (powerpc-eabi-gcc-4-4-2 -O3 -S gcc-test.cpp -o
gcc-test-442.s):
li 0,2
li 3,0
rlwimi 3,0,30,0,1
li 0,3
rlwimi 3,0,20,10,11
li 0,1
rlwimi 3,0,18,12,13
blr
Output under 2.9.5 (powerpc-eabi-gcc-2-9-5 -O3 -S gcc-test.cpp -o
gcc-test-295.s):
lis 3,0x8034
blr
Is there any way to improve this behaviour? I have been using 2.9.5 very
successfully for years and am now looking at 4.4.2, but have many such
examples in my code (for clarity of commenting and maintainability).
I have also noticed that 4.4.2 seems to use significantly larger stack
frames, and consequently more register-stacking instructions than 2.9.5
for the same functions. Am I missing something? Many thanks if you can
shed any light on this.
Mark
*****************************************************************
This email has been checked by the altohiway Mailcontroller Service
*****************************************************************