This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

optimization/9591: Partially unoptimized assembly when inline function operates on bit fields


>Number:         9591
>Category:       optimization
>Synopsis:       Partially unoptimized assembly when inline function operates on bit fields
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 06 02:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     gcc
>Release:        2.95.2
>Organization:
>Environment:
powerpc-linux-gcc running on SunOS
>Description:
Compiling the code fragment below with -O2 (or -O3) results in partially unoptimized code. Specifically, the 0/1 values of r9 should be propogated, removing branches, etc.

Code fragment:

void g();

struct {
    unsigned int a : 1, b : 1;
} bitfield;

static inline int test(void) {
    return (bitfield.a == 1 || bitfield.b == 0);
}

void f(void) {
    if (test())
	g();
}

Assembly output:

        ...
        lis 9,bitfield@ha
        lwz 0,bitfield@l(9)
        li 9,0
        cmpwi 0,0,0
        bc 12,0,.L7
        andis. 11,0,16384
        bc 4,2,.L8
.L7:
        li 9,1
.L8:
        cmpwi 0,9,0
        bc 12,2,.L6
        ...
>How-To-Repeat:
powerpc-linux-gcc -O2 -S -o - temp.c
  or
powerpc-linux-gcc -O3 -S -o - temp.c
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]