Hi All,

 For the fllowing code:

typedef struct {
 int f1:1;
 int f2:1;
 int f3:1;
 int f4:29;
} t1;

typedef struct {
 int f1:1;
 int f2:1;
 int f3:30;
} t2;

t1 s1;
t2 s2;

void func1(void)
{
 s1.f1 = s2.f1;
 s1.f2 = s2.f2;
}

we get (x86_64 target):

 movzbl  s2(%rip), %edx
 movzbl  s1(%rip), %eax
 movl    %edx, %ecx
 andl    $-4, %eax
 andl    $2, %edx        
 andl    $1, %ecx
 orl     %ecx, %eax
 orl     %edx, %eax
 movb    %al, s1(%rip)
 ret


Could gcc optimize two or more operations in adjacent bitfields into one 
operation ?


regards,
Alex R. Prado



Reply via email to