http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54985
Bug #: 54985
Summary: Dom optimization erroneous remove conditional goto.
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: [email protected]
ReportedBy: [email protected]
Attached test case fails if compiled with -O1 and higher.
gcc -O0 -m32 q.c qm.c ; ./a.out && echo "pass" || echo "FAIL"
pass
gcc -g3 -O1 -m32 q.c qm.c ; ./a.out && echo "pass" || echo "FAIL"
FAIL
gcc -v
Using built-in specs.
COLLECT_GCC=/export/users/vbyakovl/workspaces/gcc/install-ref/bin/gcc
COLLECT_LTO_WRAPPER=/export/users/vbyakovl/workspaces/gcc/install-ref/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure CFLAGS='-O0 -g3'
--prefix=/export/users/vbyakovl/workspaces/gcc/install-ref --disable-bootstrap
--enable-languages=c,c++,fortran,lto CXXFLAGS='-O0 -g3' : (reconfigured)
../gcc/configure CFLAGS='-O0 -g3'
--prefix=/export/users/vbyakovl/workspaces/gcc/install-ref --disable-bootstrap
CXXFLAGS='-O0 -g3' --enable-languages=c,c++,fortran,lto --no-create
--no-recursion : (reconfigured) ../gcc/configure CFLAGS='-O0 -g3'
--prefix=/export/users/vbyakovl/workspaces/gcc/install-ref --disable-bootstrap
CXXFLAGS='-O0 -g3' --enable-languages=c,c++,fortran,lto --no-create
--no-recursion
Thread model: posix
gcc version 4.8.0 20121015 (experimental) (GCC)
Wrong compilation of a routine
int foo(ST *s, int c)
{
int first = 1;
int count = c;
ST *item = s;
int a = s->a;
int x;
while (count--)
{
x = item->a;
if (first)
first = 0;
else if (x >= a)
return 1;
a = x;
item++;
}
return 0;
}
Compiler sets equivalence between ‘x’ and ‘a’ (routine tree-ssa-threadedge.c
/record_temporary_equivalences_from_phis() ) and folds comparison x >= a to
true.