This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
optimization/9387: jump threading bug
- From: Svein dot Seldal at solidas dot com
- To: gcc-gnats at gcc dot gnu dot org
- Cc: m dot hayes at elec dot canterbury dot ac dot nz
- Date: 21 Jan 2003 14:13:59 -0000
- Subject: optimization/9387: jump threading bug
- Reply-to: Svein dot Seldal at solidas dot com
>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: