https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118992
Bug ID: 118992
Summary: Redundant argument set up for tail call
Product: gcc
Version: 14.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: hjl.tools at gmail dot com
Target Milestone: ---
Target: x86-64
[hjl@gnu-tgl-3 pr47253]$ cat j5.c
void bar0 (int);
void bar1 (int);
void
foo (int i)
{
switch (i)
{
case 0: bar0 (i); break;
case 1: bar1 (i); break;
}
}
[hjl@gnu-tgl-3 pr47253]$ make j5.s
/export/build/gnu/tools-build/gcc-gitlab-debug/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/tools-build/gcc-gitlab-debug/build-x86_64-linux/gcc/ -O2 -S
j5.c
[hjl@gnu-tgl-3 pr47253]$ cat j5.s
.file "j5.c"
.text
.p2align 4
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
testl %edi, %edi
je .L2
cmpl $1, %edi
je .L3
ret
.p2align 4,,10
.p2align 3
.L3:
movl $1, %edi <<<< This is redundant.
jmp bar1
.p2align 4,,10
.p2align 3
.L2:
xorl %edi, %edi <<< This is redundant.
jmp bar0
.cfi_endproc
.LFE0:
.size foo, .-foo
.ident "GCC: (GNU) 15.0.1 20250221 (experimental)"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-tgl-3 pr47253]$