public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111292] New: Missed Dead Code Elimination since r14-2228-g02460c0b8c9
@ 2023-09-05 14:56 theodort at inf dot ethz.ch
2023-09-05 21:03 ` [Bug tree-optimization/111292] [14 Regression] " pinskia at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-09-05 14:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111292
Bug ID: 111292
Summary: Missed Dead Code Elimination since
r14-2228-g02460c0b8c9
Product: gcc
Version: 14.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: ---
https://godbolt.org/z/sxj43ojn3
Given the following code:
void foo(void);
static struct {
int a;
char b;
} c;
static int d, f, g;
static int *e = &d, *h, *i;
static int **j = &h;
int main() {
{
short k = d;
int l;
for (; c.a; c.a--) {
int **m = 0;
int *n = &l;
if (*e)
g = *i != 0;
else
__builtin_unreachable();
f = 8;
for (; f; f--) {
*n = c.b || k;
if ((k && *i) + g) {
int ***o = &m;
*o = j;
} else
i = &g;
}
if (m == 0 || m == &h)
;
else
foo();
;
}
}
}
gcc-trunk -O3 does not eliminate the call to foo:
main:
movl c(%rip), %eax
pushq %rbx
movzwl d(%rip), %ebx
testl %eax, %eax
je .L37
.p2align 4,,10
.p2align 3
.L2:
movq i(%rip), %rcx
xorl %esi, %esi
movl (%rcx), %edx
testl %edx, %edx
setne %sil
cmpb $0, c+4(%rip)
movl %esi, g(%rip)
jne .L3
testw %bx, %bx
jne .L4
testl %edx, %edx
jne .L5
movl $0, f(%rip)
movq $g, i(%rip)
.L6:
subl $1, %eax
movl %eax, c(%rip)
jne .L2
.L37:
xorl %eax, %eax
popq %rbx
ret
.p2align 4,,10
.p2align 3
.L3:
testw %bx, %bx
je .L45
movl (%rcx), %esi
movl %edx, %edi
orl %esi, %edi
je .L28
xorl %edi, %edi
testl %esi, %esi
je .L46
.p2align 4,,10
.p2align 3
.L23:
movl $0, f(%rip)
movl $h, %esi
testb %dil, %dil
je .L6
.L24:
movq %rcx, i(%rip)
.L11:
testq %rsi, %rsi
je .L6
cmpq $h, %rsi
je .L6
call foo
movl c(%rip), %eax
subl $1, %eax
movl %eax, c(%rip)
jne .L2
jmp .L37
.p2align 4,,10
.p2align 3
.L4:
testl %edx, %edx
jne .L5
movl $0, f(%rip)
movl (%rcx), %esi
testl %esi, %esi
je .L43
.L8:
movl $h, %esi
jmp .L11
.p2align 4,,10
.p2align 3
.L45:
movl $0, f(%rip)
testl %edx, %edx
jne .L8
.L43:
movq $g, i(%rip)
jmp .L6
.p2align 4,,10
.p2align 3
.L5:
movl $0, f(%rip)
jmp .L6
.L28:
movl $1, %edi
movl $g, %ecx
xorl %esi, %esi
.L12:
movl (%rcx), %r8d
movl %edx, %r9d
orl %r8d, %r9d
jne .L47
movl $1, %edi
movl $g, %ecx
.L14:
movl (%rcx), %r8d
movl %edx, %r10d
orl %r8d, %r10d
je .L31
movl $h, %esi
testl %r8d, %r8d
jne .L23
.L15:
movl (%rcx), %r8d
movl %edx, %r11d
orl %r8d, %r11d
je .L32
movl $h, %esi
testl %r8d, %r8d
jne .L23
.L16:
movl (%rcx), %r8d
movl %edx, %r11d
orl %r8d, %r11d
je .L33
movl $h, %esi
testl %r8d, %r8d
jne .L23
.L18:
movl (%rcx), %r8d
movl %edx, %r10d
orl %r8d, %r10d
je .L48
testl %r8d, %r8d
jne .L23
movl $h, %esi
testl %edx, %edx
jne .L27
.L21:
movl $1, %edi
movl $g, %ecx
.L27:
orl (%rcx), %edx
jne .L23
xorl %ecx, %ecx
movl %ecx, f(%rip)
movl $g, %ecx
jmp .L24
.L47:
movl $h, %esi
testl %r8d, %r8d
jne .L23
jmp .L14
.L48:
cmpl $0, g(%rip)
je .L21
xorl %edx, %edx
movl $g, %ecx
movl $h, %esi
movl %edx, f(%rip)
jmp .L24
.L31:
movl $1, %edi
movl $g, %ecx
jmp .L15
.L32:
movl $1, %edi
movl $g, %ecx
jmp .L16
.L33:
movl $1, %edi
movl $g, %ecx
jmp .L18
.L46:
movl $h, %esi
jmp .L12
gcc-13.2.0 -O3 eliminates the call to foo:
main:
movl c(%rip), %eax
movzwl d(%rip), %edi
testl %eax, %eax
je .L13
.p2align 4,,10
.p2align 3
.L2:
movq i(%rip), %rdx
xorl %ecx, %ecx
movl (%rdx), %esi
testl %esi, %esi
setne %cl
movl %ecx, g(%rip)
jne .L7
testw %di, %di
je .L14
movl (%rdx), %edx
testl %edx, %edx
je .L14
.L7:
movl $0, f(%rip)
.L6:
subl $1, %eax
movl %eax, c(%rip)
jne .L2
.L13:
xorl %eax, %eax
ret
.p2align 4,,10
.p2align 3
.L14:
movl $0, f(%rip)
movq $g, i(%rip)
jmp .L6
Bisects to r14-2228-g02460c0b8c9
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-05-07 7:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-05 14:56 [Bug tree-optimization/111292] New: Missed Dead Code Elimination since r14-2228-g02460c0b8c9 theodort at inf dot ethz.ch
2023-09-05 21:03 ` [Bug tree-optimization/111292] [14 Regression] " pinskia at gcc dot gnu.org
2023-09-05 21:06 ` pinskia at gcc dot gnu.org
2023-11-24 4:36 ` pinskia at gcc dot gnu.org
2024-03-07 23:21 ` law at gcc dot gnu.org
2024-05-07 7:41 ` [Bug tree-optimization/111292] [14/15 " rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).