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/9387: jump threading bug


>Number:         9387
>Category:       optimization
>Synopsis:       jump threading bug
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 21 14:16:02 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Svein.Seldal@solidas.com
>Release:        gcc: gcc-3_3-branch checked out 20030118, compiled for target tic4x
>Organization:
>Environment:
Cygwin 1.3.15 with gcc 3.2.1, binutils 2.13.2
>Description:
Compilation of the following code generates invalid code. I compile the code with "tic4x-gcc -O2 -g -c gcc_bug.c -o gcc_bug.o".

The code executes the first "if" block conditionally (which is OK). But the second one is executed regardless of the value of tc.

According to the maintainer, the RTL emit is OK, so this is a bug in the jump threading code. I am not able to provoke this error on i386 host native, nor the AVR target.


CODE:
-----

typedef unsigned int uint;
typedef struct _Task {
    uint Context[33];
    struct _Task *Next;
} Task;
extern Task *CurrentTask;
extern Task *_TaskHead;


Task *_GetNextTask(Task *tc)
{
    if(tc)
    {
        tc = CurrentTask->Next;
    }
    if(!tc)
    {
        tc = _TaskHead;
    }
    return tc;
}
>How-To-Repeat:
tic4x-gcc -O2 -g -c gcc_bug.c -o gcc_bug.o
>Fix:
Either compile the code without the -O2 option or use the -fno-thread-jumps option:

tic4x-gcc -O2 -g -c gcc_bug.c -o gcc_bug.o -fno-thread-jumps
>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]