https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102650
Bug ID: 102650
Summary: Dead Code Elimination Regression at -O3 (trunk vs
11.2.0)
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: theodort at inf dot ethz.ch
Target Milestone: ---
cat case.c
bisections
static int a = 2, b, c, d;
void foo(void);
int main() {
short e;
int f = -1;
if (b)
c = 0;
c || (f = 2);
for (; d < 1; d++)
e = f + a;
if (!e)
foo();
return 0;
}
11.2.0 at -O3 can eliminate the call to foo but trunk at -O3 cannot:
gcc-11 -v
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (GCC)
gcc-11 -O3 case.c -S -o /dev/stdout
...
main:
.LFB0:
.cfi_startproc
movl d(%rip), %eax
testl %eax, %eax
jg .L2
movl $1, d(%rip)
.L2:
xorl %eax, %eax
ret
gcc-trunk -v
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 20211008 (experimental) (GCC)
gcc-trunk -O3 case.c -S -o /dev/stdout
...
main:
.LFB0:
.cfi_startproc
movl d(%rip), %ecx
testl %ecx, %ecx
jg .L3
movl $1, d(%rip)
xorl %eax, %eax
ret
.L3:
pushq %rax
.cfi_def_cfa_offset 16
call foo
xorl %eax, %eax
popq %rdx
.cfi_def_cfa_offset 8
ret
18b88412069f51433e1b4f440d3c035bfc7b5cca
(https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=18b88412069f51433e1b4f440d3c035bfc7b5cca)
introduced this regression