[Bug tree-optimization/111013] New: [14 Regression] Dead Code Elimination Regression at -O2 since r14-338-g1dd154f6407

2023-08-14 Thread scherrer.sv at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111013

Bug ID: 111013
   Summary: [14 Regression] Dead Code Elimination Regression at
-O2 since r14-338-g1dd154f6407
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: scherrer.sv at gmail dot com
  Target Milestone: ---

static int b, c, e;
static unsigned d;
static short f;
void foo(void);
void(a)();
static char g(int h) {
  int i = 2749857453;
j:
  a();
k:
  if (b)
goto j;
  f = 1;
  if ((unsigned)(7 ^ e | (h & d && f)) >= 2)
i = 0;
  e = 0;
  if (c)
goto k;
  if (!(i <= 6))
foo();
  return h;
}
int main() {
  d--;
  b = c = e && g(1);
}

gcc-9ec5d6de735 (trunk) -O2 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O2 can.
---
gcc-9ec5d6de7355c15b3811150d1581dab5bd489966 -O2 case.c -S -o case.s
- OUTPUT -
main:
.LFB1:
.cfi_startproc
subq$8, %rsp
.cfi_def_cfa_offset 16
movle(%rip), %eax
subl$1, d(%rip)
testl   %eax, %eax
jne .L3
.L2:
movl%eax, c(%rip)
movl%eax, b(%rip)
xorl%eax, %eax
addq$8, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L3:
.cfi_restore_state
xorl%eax, %eax
calla
movlb(%rip), %edx
testl   %edx, %edx
jne .L3
movld(%rip), %ecx
movle(%rip), %eax
movl$-1545109843, %edx
xorl%esi, %esi
movlc(%rip), %edi
andl$1, %ecx
jmp .L5
.p2align 4,,10
.p2align 3
.L8:
xorl%eax, %eax
.L5:
xorl$7, %eax
orl %ecx, %eax
cmpl$2, %eax
cmovnb  %esi, %edx
testl   %edi, %edi
jne .L8
xorl%eax, %eax
movl%eax, e(%rip)
cmpl$6, %edx
jg  .L15
.L6:
movl$1, %eax
jmp .L2
.L15:
callfoo
jmp .L6
-- END OUTPUT -

---
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O2 case.c -S -o case.s
- OUTPUT -
main:
.LFB1:
.cfi_startproc
subq$8, %rsp
.cfi_def_cfa_offset 16
movle(%rip), %eax
subl$1, d(%rip)
testl   %eax, %eax
jne .L3
.L2:
movl%eax, c(%rip)
movl%eax, b(%rip)
xorl%eax, %eax
addq$8, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L3:
.cfi_restore_state
xorl%eax, %eax
calla
movlb(%rip), %edx
movlc(%rip), %eax
testl   %edx, %edx
jne .L3
testl   %eax, %eax
je  .L4
.L5:
jmp .L5
.L4:
xorl%eax, %eax
movl%eax, e(%rip)
movl$1, %eax
jmp .L2
-- END OUTPUT -

---
Bisects to r14-338-g1dd154f6407

[Bug tree-optimization/111012] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-573-g69f1a8af45d

2023-08-14 Thread scherrer.sv at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111012

Bug ID: 111012
   Summary: [14 Regression] Dead Code Elimination Regression at
-O3 since r14-573-g69f1a8af45d
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: scherrer.sv at gmail dot com
  Target Milestone: ---

static int b, c;
static char d;
static short e = -1L;
static int *j = 
void foo(void);
void bar150_(void);
void bar173_(void);
static char(a)(char k, char l) { return k + l; }
static void g(unsigned k, int l) {
  if (l)
if (!k)
  foo();
  if (k)
bar150_();
}
static const unsigned char h();
static char i(int k) {
  if (k)
bar173_();
  c <= 0 >= b;
  if (k)
return c;
  return c;
}
static void f(char k, unsigned) {
  char m = h(8 != c);
  g(m && 8, k);
}
static const unsigned char h(int k) {
  d = i(c);
  *j = a(e, d < k < k && c) ^ k;
  b = 0;
  return c;
}
int main() { f(c, b); }

gcc-9ec5d6de735 (trunk) -O3 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O3 can.
---
gcc-9ec5d6de7355c15b3811150d1581dab5bd489966 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB5:
.cfi_startproc
pushq   %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
pushq   %rbx
.cfi_def_cfa_offset 24
.cfi_offset 3, -24
subq$8, %rsp
.cfi_def_cfa_offset 32
movlc(%rip), %ebx
cmpl$8, %ebx
setne   %bpl
testl   %ebx, %ebx
jne .L9
movl$-2, c(%rip)
xorl%eax, %eax
movl%eax, b(%rip)
.L4:
callbar150_
.L6:
addq$8, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 24
xorl%eax, %eax
popq%rbx
.cfi_def_cfa_offset 16
popq%rbp
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L9:
.cfi_restore_state
callbar173_
movlc(%rip), %edx
movzbl  %bpl, %ebp
movl$0, b(%rip)
movsbl  %dl, %eax
cmpl%eax, %ebp
setg%al
movzbl  %al, %eax
cmpl%eax, %ebp
setg%al
testl   %edx, %edx
setne   %dl
andl%edx, %eax
subl$1, %eax
movsbl  %al, %eax
xorl%ebp, %eax
movl%eax, c(%rip)
testb   %bl, %bl
je  .L3
testb   %al, %al
jne .L4
callfoo
jmp .L6
.L3:
testb   %al, %al
je  .L6
jmp .L4
-- END OUTPUT -

---
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB5:
.cfi_startproc
movlc(%rip), %eax
pushq   %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
xorl%ebx, %ebx
cmpl$8, %eax
setne   %bl
testl   %eax, %eax
jne .L10
.L2:
cmpl%eax, %ebx
setg%al
movzbl  %al, %eax
cmpl%eax, %ebx
jg  .L3
notl%ebx
.L4:
movl%ebx, c(%rip)
movl$0, b(%rip)
callbar150_
xorl%eax, %eax
popq%rbx
.cfi_remember_state
.cfi_def_cfa_offset 8
ret
.L3:
.cfi_restore_state
cmpl$1, c(%rip)
sbbb%bl, %bl
xorl$1, %ebx
movsbl  %bl, %ebx
jmp .L4
.L10:
callbar173_
movsbl  c(%rip), %eax
jmp .L2
-- END OUTPUT -

---
Bisects to r14-573-g69f1a8af45d

[Bug tree-optimization/111003] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2161-g237e83e2158

2023-08-12 Thread scherrer.sv at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111003

Bug ID: 111003
   Summary: [14 Regression] Dead Code Elimination Regression at
-O3 since r14-2161-g237e83e2158
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: scherrer.sv at gmail dot com
  Target Milestone: ---

static int c, d, e, f;
static short g;
static int *h = 
void foo(void);
short(a)();
static unsigned b(unsigned char j, int l) { return j > l ? j : j << l; }
static int *i();
static void k(int j, unsigned char l) {
  i();
  g = f;
  f = g;
  for (; g;) {
int m;
d = a();
for (; d;) {
  if (l)
if (!(j >= -639457069 && j <= -639457069))
  if (m)
foo();
  m = (10 != (l ^ b(j, 6))) < (0 > e);
}
  }
}
static int *i() {
  for (; e; e = a(e, 6))
;
  return h;
}
int main() { k(c, c); }

gcc-8441841a1b9 (trunk) -O3 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O3 can.
---
gcc-8441841a1b985d68245954af1ff023db121b0635 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB3:
.cfi_startproc
pushq   %r13
.cfi_def_cfa_offset 16
.cfi_offset 13, -16
pushq   %r12
.cfi_def_cfa_offset 24
.cfi_offset 12, -24
pushq   %rbp
.cfi_def_cfa_offset 32
.cfi_offset 6, -32
pushq   %rbx
.cfi_def_cfa_offset 40
.cfi_offset 3, -40
subq$8, %rsp
.cfi_def_cfa_offset 48
movle(%rip), %edi
movlc(%rip), %ebx
testl   %edi, %edi
je  .L5
.p2align 4,,10
.p2align 3
.L2:
movl$6, %esi
xorl%eax, %eax
calla
movswl  %ax, %edi
movl%edi, e(%rip)
testl   %edi, %edi
jne .L2
.L5:
movlf(%rip), %eax
movswl  %ax, %edx
movw%ax, g(%rip)
movl%edx, f(%rip)
testw   %ax, %ax
je  .L36
movzbl  %bl, %ebp
testb   %bl, %bl
je  .L39
movl%ebp, %eax
sall$6, %eax
xorl%ebp, %eax
cmpl$10, %eax
setne   %r12b
.p2align 4,,10
.p2align 3
.L18:
xorl%eax, %eax
calla
cwtl
movl%eax, d(%rip)
testl   %eax, %eax
je  .L14
cmpl$-639457069, %ebx
jne .L17
.L19:
jmp .L19
.p2align 4,,10
.p2align 3
.L16:
cmpl$6, %ebp
jg  .L20
movle(%rip), %eax
xorl%r13d, %r13d
shrl$31, %eax
cmpb%al, %r12b
setb%r13b
.p2align 4,,10
.p2align 3
.L17:
testl   %r13d, %r13d
je  .L16
callfoo
movle(%rip), %eax
shrl$31, %eax
cmpl$6, %ebp
setg%dl
xorl%r13d, %r13d
orl %r12d, %edx
cmpb%al, %dl
movld(%rip), %eax
setb%r13b
testl   %eax, %eax
jne .L17
.L14:
cmpw$0, g(%rip)
jne .L18
.L36:
addq$8, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 40
xorl%eax, %eax
popq%rbx
.cfi_def_cfa_offset 32
popq%rbp
.cfi_def_cfa_offset 24
popq%r12
.cfi_def_cfa_offset 16
popq%r13
.cfi_def_cfa_offset 8
ret
.L39:
.cfi_restore_state
cmpl$6, %ebp
jg  .L7
.p2align 4,,10
.p2align 3
.L10:
xorl%eax, %eax
calla
cwtl
movl%eax, d(%rip)
testl   %eax, %eax
je  .L8
.L9:
jmp .L9
.p2align 4,,10
.p2align 3
.L12:
cmpw$0, g(%rip)
je  .L36
.L7:
xorl%eax, %eax
calla
cwtl
movl%eax, d(%rip)
testl   %eax, %eax
je  .L12
.L13:
jmp .L13
.p2align 4,,10
.p2align 3
.L8:
cmpw$0, g(%rip)
jne .L10
jmp .L36
.p2align 4,,10
.p2align 3
.L20:
cmpl$-639457069, %ebx
jne .L20
jmp .L19
-- END OUTPUT -

---
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB3:
.cfi_startproc
movle(%rip), %edi
pushq   %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
movlc(%rip), %ebx
testl   %edi, %edi
je  .L5
.p2align 4,,10
.p2align 3
.L2:
movl$6, %esi
xorl%eax, 

[Bug tree-optimization/110992] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-1654-g7ceed7e3e29

2023-08-11 Thread scherrer.sv at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110992

Bug ID: 110992
   Summary: [14 Regression] Dead Code Elimination Regression at
-O3 since r14-1654-g7ceed7e3e29
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: scherrer.sv at gmail dot com
  Target Milestone: ---

static unsigned b;
static short c = 4;
void foo(void);
static short(a)(short d, short g) { return d * g; }
void e();
static char f() {
  b = 0;
  return 0;
}
int main() {
  int h = b;
  if ((short)(a(c && e, 65535) & h)) {
foo();
h || f();
  }
}

gcc-bcda361daae (trunk) -O3 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O3 can.
---
gcc-bcda361daaec8623c91d0dff3ea8e576373b5f50 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB2:
.cfi_startproc
cmpw$0, b(%rip)
jne .L8
xorl%eax, %eax
ret
.L8:
pushq   %rax
.cfi_def_cfa_offset 16
callfoo
xorl%eax, %eax
popq%rdx
.cfi_def_cfa_offset 8
ret
-- END OUTPUT -

---
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB2:
.cfi_startproc
xorl%eax, %eax
ret
-- END OUTPUT -

---
Bisects to r14-1654-g7ceed7e3e29

[Bug tree-optimization/110991] New: [14 Regression] Dead Code Elimination Regression at -O2 since r14-1135-gc53f51005de

2023-08-11 Thread scherrer.sv at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110991

Bug ID: 110991
   Summary: [14 Regression] Dead Code Elimination Regression at
-O2 since r14-1135-gc53f51005de
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: scherrer.sv at gmail dot com
  Target Milestone: ---

static unsigned char a;
static char b;
void foo(void);
int main() {
  a = 25;
  for (; a > 13; --a)
b = a > 127 ?: a << 3;
  if (!b)
foo();
}

gcc-3a13884b23a (trunk) -O2 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O2 can.
---
gcc-3a13884b23ae32b43d56d68a9c6bd4ce53d60017 -O2 case.c -S -o case.s
- OUTPUT -
main:
.LFB0:
.cfi_startproc
movd.LC0(%rip), %xmm0
movd.LC1(%rip), %xmm1
xorl%eax, %eax
.L2:
addl$1, %eax
movdqa  %xmm0, %xmm2
paddb   %xmm1, %xmm0
cmpl$3, %eax
jne .L2
movdqa  %xmm2, %xmm0
movb$13, a(%rip)
paddb   %xmm2, %xmm0
paddb   %xmm0, %xmm0
movdqa  %xmm0, %xmm1
paddb   %xmm0, %xmm1
pxor%xmm0, %xmm0
pcmpgtb %xmm2, %xmm0
movd.LC2(%rip), %xmm2
pand%xmm0, %xmm2
pandn   %xmm1, %xmm0
por %xmm2, %xmm0
movd%xmm0, %eax
sarl$24, %eax
movb%al, b(%rip)
testb   %al, %al
je  .L10
xorl%eax, %eax
ret
.L10:
pushq   %rax
.cfi_def_cfa_offset 16
callfoo
xorl%eax, %eax
popq%rdx
.cfi_def_cfa_offset 8
ret
-- END OUTPUT -

---
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O2 case.c -S -o case.s
- OUTPUT -
main:
.LFB0:
.cfi_startproc
movb$112, b(%rip)
xorl%eax, %eax
movb$13, a(%rip)
ret
-- END OUTPUT -

---
Bisects to r14-1135-gc53f51005de

[Bug tree-optimization/110942] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8

2023-08-08 Thread scherrer.sv at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110942

Bug ID: 110942
   Summary: [14 Regression] Dead Code Elimination Regression at
-O3 since r14-1165-g257c2be7ff8
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: scherrer.sv at gmail dot com
  Target Milestone: ---

static int b, c;
static short d;
static char e;
void bar49_(void);
void bar115_(void);
void bar42_(void);
void foo(void);
static short(a)(short f, short g) { return f + g; }
static int h() {
  short i = 0;
  char j;
  int k;
l:
  k = 0;
  if (i)
bar42_();
  i = 0;
  for (; i != 8; i = a(i, 8)) {
if (e)
  bar49_();
if (0 >= i)
  c = 0;
if (!k) {
  j = 6;
  for (; j >= 0; j--) {
k = 0;
for (; k <= 0; k++) {
  if (!(j >= 5))
bar115_();
  for (; d; d = 0) {
if (!j)
  foo();
if (j)
  break;
  }
  if (i)
break;
}
if (c)
  return j;
c = 2;
if (b)
  goto l;
  }
}
  }
  return 0;
}
int main() { h(); }

gcc-25c4b1620eb (trunk) -O3 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O3 can.
---
gcc-25c4b1620ebc10fceabd86a34fdbbaf8037e7e82 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB2:
.cfi_startproc
pushq   %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
xorl%eax, %eax
movl$6, %ebx
.L2:
movl%eax, c(%rip)
cmpb$4, %bl
jne .L18
.L7:
callbar115_
cmpw$0, d(%rip)
je  .L8
testb   %bl, %bl
jne .L8
callfoo
movlc(%rip), %edx
xorl%eax, %eax
movw%ax, d(%rip)
testl   %edx, %edx
jne .L5
movl$2, c(%rip)
.L5:
xorl%eax, %eax
popq%rbx
.cfi_remember_state
.cfi_def_cfa_offset 8
ret
.L18:
.cfi_restore_state
testl   %eax, %eax
jne .L5
subl$1, %ebx
movl$2, %eax
jmp .L2
.L8:
cmpl$0, c(%rip)
jne .L5
movl$2, c(%rip)
subl$1, %ebx
cmpb$-1, %bl
jne .L7
jmp .L5
-- END OUTPUT -

---
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB2:
.cfi_startproc
movl$2, c(%rip)
xorl%eax, %eax
ret
-- END OUTPUT -

---
Bisects to r14-1165-g257c2be7ff8

[Bug tree-optimization/110941] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c

2023-08-08 Thread scherrer.sv at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110941

Bug ID: 110941
   Summary: [14 Regression] Dead Code Elimination Regression at
-O3 since r14-2379-gc496d15954c
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: scherrer.sv at gmail dot com
  Target Milestone: ---

static int a;
void foo(void);
void bar349_(void);
void bar363_(void);
void bar275_(void);
int main() {
  {
{
  short b = 26;
  for (; b >= 1; b = b - 4) {
if (b >= 2 && b <= 26)
  bar275_();
if (a)
  bar363_();
if (a)
  bar349_();
int c = b;
if (!(c >= 2 && c <= 26))
  foo();
  }
}
a = 0;
  }
}

gcc-25c4b1620eb (trunk) -O3 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O3 can.
---
gcc-25c4b1620ebc10fceabd86a34fdbbaf8037e7e82 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB0:
.cfi_startproc
pushq   %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
movl$24, %ebx
.p2align 4,,10
.p2align 3
.L8:
cmpw$24, %bx
jbe .L2
movla(%rip), %edx
testl   %edx, %edx
jne .L3
.L7:
callfoo
xorl%eax, %eax
popq%rbx
.cfi_remember_state
.cfi_def_cfa_offset 8
movl$0, a(%rip)
ret
.p2align 4,,10
.p2align 3
.L3:
.cfi_restore_state
callbar363_
movla(%rip), %eax
testl   %eax, %eax
je  .L7
callbar349_
jmp .L7
.L2:
callbar275_
cmpl$0, a(%rip)
jne .L15
.p2align 4,,10
.p2align 3
.L6:
subl$4, %ebx
cmpl$-4, %ebx
jne .L8
movl$0, a(%rip)
xorl%eax, %eax
popq%rbx
.cfi_remember_state
.cfi_def_cfa_offset 8
ret
.L15:
.cfi_restore_state
callbar363_
cmpl$0, a(%rip)
je  .L6
callbar349_
cmpl$24, %ebx
jbe .L6
jmp .L7
-- END OUTPUT -

---
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB0:
.cfi_startproc
pushq   %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
movl$24, %ebx
.L10:
cmpw$24, %bx
jbe .L2
movla(%rip), %edx
testl   %edx, %edx
jne .L17
.L3:
movl$0, a(%rip)
xorl%eax, %eax
popq%rbx
.cfi_remember_state
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L17:
.cfi_restore_state
callbar363_
movla(%rip), %eax
testl   %eax, %eax
jne .L4
.L15:
subl$4, %ebx
jmp .L10
.p2align 4,,10
.p2align 3
.L4:
callbar349_
jmp .L15
.L2:
callbar275_
cmpl$0, a(%rip)
jne .L18
.p2align 4,,10
.p2align 3
.L9:
subl$4, %ebx
cmpw$-4, %bx
jne .L10
jmp .L3
.L18:
callbar363_
cmpl$0, a(%rip)
je  .L9
callbar349_
jmp .L9
-- END OUTPUT -

---
Bisects to r14-2379-gc496d15954c

[Bug tree-optimization/110919] [14 Regression] Dead Code Elimination Regression at -O3 since r14-1691-gbc5a2c2e793

2023-08-06 Thread scherrer.sv at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110919

--- Comment #1 from Scherrer Svenja  ---
My apologies, the assembly above is incomplete. The following shows the bug

gcc-87b0749cfb9406790b108208b466cf507ae3c431 -O3 case.c -S -o case.s
- OUTPUT -
.file   "case.c"
.text
.p2align 4
.type   g, @function
g:
.LFB3:
.cfi_startproc
pushq   %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
movl%esi, %ebx
testw   %di, %di
jne .L2
xorl%eax, %eax
testl   %esi, %esi
sete%al
.L3:
movle(%rip), %edx
cmpl%eax, %edx
sete%cl
testl   %edx, %edx
setne   %dl
testb   %dl, %cl
je  .L1
testl   %eax, %eax
je  .L15
.L1:
popq%rbx
.cfi_remember_state
.cfi_def_cfa_offset 8
ret
.L2:
.cfi_restore_state
callbar151_
testl   %ebx, %ebx
je  .L1
callbar162_
xorl%eax, %eax
jmp .L3
.L15:
popq%rbx
.cfi_def_cfa_offset 8
jmp foo
.cfi_endproc
.LFE3:
.size   g, .-g
.section.text.startup,"ax",@progbits
.p2align 4
.globl  main
.type   main, @function
main:
.LFB4:
.cfi_startproc
subq$8, %rsp
.cfi_def_cfa_offset 16
movl$4, %esi
xorl%edi, %edi
callg
xorl%esi, %esi
xorl%edi, %edi
callg
movl$-1, %esi
xorl%edi, %edi
callg
xorl%eax, %eax
addq$8, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE4:
.size   main, .-main
.local  e
.comm   e,4,4
.ident  "GCC: (GNU) 14.0.0 20230806 (experimental)"
.section.note.GNU-stack,"",@progbits

-- END OUTPUT -

---
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O3 case.c -S -o case.s
- OUTPUT -
.file   "case.c"
.text
.p2align 4
.type   g, @function
g:
.LFB3:
.cfi_startproc
testw   %di, %di
jne .L11
ret
.L11:
pushq   %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
movl%esi, %ebx
callbar151_
testl   %ebx, %ebx
je  .L1
popq%rbx
.cfi_remember_state
.cfi_restore 3
.cfi_def_cfa_offset 8
jmp bar162_
.L1:
.cfi_restore_state
popq%rbx
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE3:
.size   g, .-g
.section.text.startup,"ax",@progbits
.p2align 4
.globl  main
.type   main, @function
main:
.LFB4:
.cfi_startproc
subq$8, %rsp
.cfi_def_cfa_offset 16
movl$4, %esi
xorl%edi, %edi
callg
xorl%esi, %esi
xorl%edi, %edi
callg
movl$-1, %esi
xorl%edi, %edi
callg
xorl%eax, %eax
addq$8, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE4:
.size   main, .-main
.ident  "GCC: (GNU) 13.1.0"
.section.note.GNU-stack,"",@progbits

-- END OUTPUT -

[Bug tree-optimization/110919] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-1691-gbc5a2c2e793

2023-08-06 Thread scherrer.sv at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110919

Bug ID: 110919
   Summary: [14 Regression] Dead Code Elimination Regression at
-O3 since r14-1691-gbc5a2c2e793
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: scherrer.sv at gmail dot com
  Target Milestone: ---

static short a, b;
static int e;
static int *j = 
void bar151_(void);
void foo(void);
void bar162_(void);
static int(d)(int k, int l) { return l == k && l - 1 ? k : 0; }
static void f();
static void g(unsigned short, unsigned);
static void h() {
  g(0, 4);
  f();
  int i = -1;
  g(0, i);
}
static void f(int k) { g(k, 0); }
static void g(unsigned short k, unsigned l) {
  if (k)
bar151_();
  if (l)
if (k)
  bar162_();
  short c = l;
  b = c == 0 || a;
  if (d(*j, b))
foo();
}
int main() { h(); }

gcc-87b0749cfb9 (trunk) -O3 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O3 can.
---
gcc-87b0749cfb9406790b108208b466cf507ae3c431 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB4:
.cfi_startproc
subq$8, %rsp
.cfi_def_cfa_offset 16
movl$4, %esi
xorl%edi, %edi
callg
xorl%esi, %esi
xorl%edi, %edi
callg
movl$-1, %esi
xorl%edi, %edi
callg
xorl%eax, %eax
addq$8, %rsp
.cfi_def_cfa_offset 8
ret
-- END OUTPUT -

---
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB4:
.cfi_startproc
subq$8, %rsp
.cfi_def_cfa_offset 16
movl$4, %esi
xorl%edi, %edi
callg
xorl%esi, %esi
xorl%edi, %edi
callg
movl$-1, %esi
xorl%edi, %edi
callg
xorl%eax, %eax
addq$8, %rsp
.cfi_def_cfa_offset 8
ret
-- END OUTPUT -

---
Bisects to r14-1691-gbc5a2c2e793

[Bug tree-optimization/110918] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2331-g018e7f16408

2023-08-06 Thread scherrer.sv at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110918

Bug ID: 110918
   Summary: [14 Regression] Dead Code Elimination Regression at
-O3 since r14-2331-g018e7f16408
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: scherrer.sv at gmail dot com
  Target Milestone: ---

static char b = 53;
static unsigned c;
void foo(void);
static int(a)(int d, int e) { return (d ^ e) < 0 ? d : d - e; }
int main() {
  {
int f = 2;
c = b;
b = 0;
for (; c <= 6;) {
  if (f >= 2)
f = 0;
  for (; f >= -9; f = a(f, 8))
if (!(f >= -8 && f <= 0))
  foo();
}
  }
}

gcc-87b0749cfb9 (trunk) -O3 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O3 can.
---
gcc-87b0749cfb9406790b108208b466cf507ae3c431 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB1:
.cfi_startproc
movsbl  b(%rip), %eax
pushq   %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
xorl%ebx, %ebx
movb$0, b(%rip)
movl%eax, c(%rip)
cmpl$6, %eax
ja  .L11
.p2align 4,,10
.p2align 3
.L2:
leal8(%rbx), %eax
cmpl$8, %eax
ja  .L16
.L3:
cmpl$-8, %ebx
je  .L5
cmpl$-1, %ebx
jl  .L6
movl$-8, %ebx
leal8(%rbx), %eax
cmpl$8, %eax
jbe .L3
.L16:
callfoo
subl$8, %ebx
jmp .L2
.L5:
jmp .L5
.p2align 4,,10
.p2align 3
.L6:
cmpl$6, c(%rip)
ja  .L11
.L8:
jmp .L8
.p2align 4,,10
.p2align 3
.L11:
xorl%eax, %eax
popq%rbx
.cfi_def_cfa_offset 8
ret
-- END OUTPUT -

---
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O3 case.c -S -o case.s
- OUTPUT -
main:
.LFB1:
.cfi_startproc
movsbl  b(%rip), %edx
xorl%eax, %eax
movb$0, b(%rip)
movl%edx, c(%rip)
cmpl$6, %edx
ja  .L8
.p2align 4,,10
.p2align 3
.L2:
testl   %eax, %eax
js  .L3
subl$8, %eax
cmpl$-9, %eax
jge .L2
cmpl$6, c(%rip)
ja  .L8
.L6:
jmp .L6
.L3:
jmp .L3
.p2align 4,,10
.p2align 3
.L8:
xorl%eax, %eax
ret
-- END OUTPUT -

---
Bisects to r14-2331-g018e7f16408

[Bug tree-optimization/110873] New: [14 Regression] Dead Code Elimination Regression at -O2 since r14-376-g47a76439911

2023-08-02 Thread scherrer.sv at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110873

Bug ID: 110873
   Summary: [14 Regression] Dead Code Elimination Regression at
-O2 since r14-376-g47a76439911
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: scherrer.sv at gmail dot com
  Target Milestone: ---

static int b;
static short c;
static char d;
static int *e = 
void foo(void);  
void bar110_(void);
static char(a)(char f, char g) { return f + g; }
int main() {
*e = 3;
unsigned char h;
c = 0;
i:
if (!b)
foo();
h = -25;
for (; h >= 7; h = a(h, 6))
for (; d; d--)
;
if (!(h >= 5))
bar110_();
if (c)
goto i;
}
---
gcc-68c3aa7510b (trunk) -O2 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O2 can
---
gcc-68c3aa7510b2f45f44379ecd77e97c88780a84ed -O2 case.c -S -o case.s
- OUTPUT -
main:
.LFB1:
.cfi_startproc
movl$3, b(%rip)
xorl%esi, %esi
movw%si, c(%rip)
.L11:
cmpb$0, d(%rip)
je  .L13
movb$0, d(%rip)
.L13:
cmpw$0, c(%rip)
je  .L15
movlb(%rip), %eax
testl   %eax, %eax
jne .L11
subq$8, %rsp
.cfi_def_cfa_offset 16
.L6:
callfoo
.L2:
cmpb$0, d(%rip)
je  .L4
movb$0, d(%rip)
.L4:
cmpw$0, c(%rip)
je  .L5
movlb(%rip), %ecx
testl   %ecx, %ecx
jne .L2
jmp .L6
.L15:
.cfi_def_cfa_offset 8
xorl%eax, %eax
ret
.L5:
.cfi_def_cfa_offset 16
xorl%eax, %eax
popq%rdx
.cfi_def_cfa_offset 8
ret
-- END OUTPUT -

---
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O2 case.c -S -o case.s
- OUTPUT -
main:
.LFB1:
.cfi_startproc
movl$3, b(%rip)
xorl%eax, %eax
cmpb$0, d(%rip)
movw%ax, c(%rip)
je  .L3
movb$0, d(%rip)
.L3:
xorl%eax, %eax
ret
-- END OUTPUT -

---
Bisects to r14-376-g47a76439911