public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/110376] New: Wrong code at -O1 on x86_64-linux-gnu
@ 2023-06-23 15:10 shaohua.li at inf dot ethz.ch
  2023-06-24  0:01 ` [Bug c/110376] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-06-23 15:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110376

            Bug ID: 110376
           Summary: Wrong code at -O1 on x86_64-linux-gnu
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shaohua.li at inf dot ethz.ch
  Target Milestone: ---

This seems to be a recent regression bug. gcc at -O1 produces wrong code.

Compiler explorer: https://godbolt.org/z/EnMfs9oxe

$ cat a.c
int f, g, a, c;
char k = 204;
char *l = &k;
short m, n;
static long b;
unsigned *h = &c;
unsigned **i = &h;
int p(char *aa) {
  aa[0] && aa[1] && aa[2];
  return 1;
}
int q(char c) {
  char d[] = {c};
  int e = p(d);
  return e;
}
int r(int j, int h) {
  f = h / 4;
  g = f * 6;
  return g;
}
short s() { return **i; }
void t() {
  for (; r(9, *l) <= 1;) {
    int j;
    long *o = &b;
    *o = 0 >= 0;
    for (; q(0) + a > 1; a++)
      *o = 0 > m;
    j = s();
    for (; a;)
      n = j;
    for (; (char)(1 + k + b) + k; --k)
      ;
  }
}
int main() { t(); }
$
$ gcc-tk -O0 a.c &&./a.out
$
$ gcc-tk -O1 a.c &&./a.out
Killed - processing time exceeded
$
$ gcc-tk -v
Using built-in specs.
COLLECT_GCC=gcc-tk
COLLECT_LTO_WRAPPER=/zdata/shaoli/compilers/ccbuilder-compilers/gcc-577223aebc7acdd31e62b33c1682fe54a622ae27/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++
--prefix=/zdata/shaoli/compilers/ccbuilder-compilers/gcc-577223aebc7acdd31e62b33c1682fe54a622ae27
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230621 (experimental) (GCC)
$

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/110376] Wrong code at -O1 on x86_64-linux-gnu
  2023-06-23 15:10 [Bug c/110376] New: Wrong code at -O1 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
@ 2023-06-24  0:01 ` pinskia at gcc dot gnu.org
  2023-07-04 10:32 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-24  0:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110376

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The underlying issue is the same as PR 110228 .


Changing b to _Bool (and o to _Bool*) and phiopt doing:
phiopt match-simplify trying:
        b_lsm_flag.31_11 != 0 ? b_lsm.30_12 : 1
Matching expression match.pd:1990, gimple-match-5.cc:23
Matching expression match.pd:1990, gimple-match-5.cc:23
Matching expression match.pd:1990, gimple-match-5.cc:23
Matching expression match.pd:1947, gimple-match-7.cc:20
Matching expression match.pd:2479, gimple-match-4.cc:35
Matching expression match.pd:2482, gimple-match-3.cc:66
Matching expression match.pd:2489, gimple-match-2.cc:58
Applying pattern match.pd:6456, gimple-match-6.cc:12915
Applying pattern match.pd:1378, gimple-match-3.cc:7714
Matching expression match.pd:1947, gimple-match-7.cc:20
Matching expression match.pd:1957, gimple-match-6.cc:46
Matching expression match.pd:1947, gimple-match-7.cc:20
Applying pattern match.pd:4745, gimple-match-2.cc:16250
Folded into the sequence:
_3 = ~b_lsm_flag.31_11;
_56 = _3 | b_lsm.30_12;
Removing basic block 9
;; basic block 9, loop depth 1
;;  pred:       8
;;  succ:       10

*** This bug has been marked as a duplicate of bug 110228 ***

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/110376] Wrong code at -O1 on x86_64-linux-gnu
  2023-06-23 15:10 [Bug c/110376] New: Wrong code at -O1 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
  2023-06-24  0:01 ` [Bug c/110376] " pinskia at gcc dot gnu.org
@ 2023-07-04 10:32 ` cvs-commit at gcc dot gnu.org
  2023-07-04 15:54 ` shaohua.li at inf dot ethz.ch
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-04 10:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110376

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:d4800a23d8d14213f9e461cd47e97a5c7271b1a9

commit r14-2291-gd4800a23d8d14213f9e461cd47e97a5c7271b1a9
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Jul 4 12:27:56 2023 +0200

    tree-optimization/110376 - testcase for fixed bug

    This is a new testcase for the fixed bug.

            PR tree-optimization/110376
            * gcc.dg/torture/pr110376.c: New testcase.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/110376] Wrong code at -O1 on x86_64-linux-gnu
  2023-06-23 15:10 [Bug c/110376] New: Wrong code at -O1 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
  2023-06-24  0:01 ` [Bug c/110376] " pinskia at gcc dot gnu.org
  2023-07-04 10:32 ` cvs-commit at gcc dot gnu.org
@ 2023-07-04 15:54 ` shaohua.li at inf dot ethz.ch
  2023-07-04 17:26 ` pinskia at gcc dot gnu.org
  2023-07-05  7:26 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-07-04 15:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110376

--- Comment #3 from Shaohua Li <shaohua.li at inf dot ethz.ch> ---
You post a commit for fixing this bug. Does this mean this report is not a DUP
of 110228?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/110376] Wrong code at -O1 on x86_64-linux-gnu
  2023-06-23 15:10 [Bug c/110376] New: Wrong code at -O1 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (2 preceding siblings ...)
  2023-07-04 15:54 ` shaohua.li at inf dot ethz.ch
@ 2023-07-04 17:26 ` pinskia at gcc dot gnu.org
  2023-07-05  7:26 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-04 17:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110376

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Shaohua Li from comment #3)
> You post a commit for fixing this bug. Does this mean this report is not a
> DUP of 110228?

The commit was just a testcase (more testcases the better really); there were 3
different issues causing PR 110228 really, 2 for phiopt, one for ifcombine.
Anyways all 3 have been fixed on the trunk. one of those 3 fixed this issue and
a testcase was added just to make sure it does not get exposed again.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/110376] Wrong code at -O1 on x86_64-linux-gnu
  2023-06-23 15:10 [Bug c/110376] New: Wrong code at -O1 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (3 preceding siblings ...)
  2023-07-04 17:26 ` pinskia at gcc dot gnu.org
@ 2023-07-05  7:26 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-05  7:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110376

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> (In reply to Shaohua Li from comment #3)
> > You post a commit for fixing this bug. Does this mean this report is not a
> > DUP of 110228?
> 
> The commit was just a testcase (more testcases the better really); there
> were 3 different issues causing PR 110228 really, 2 for phiopt, one for
> ifcombine. Anyways all 3 have been fixed on the trunk. one of those 3 fixed
> this issue and a testcase was added just to make sure it does not get
> exposed again.

And all three different issues should have been separate bugs ...

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-05  7:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-23 15:10 [Bug c/110376] New: Wrong code at -O1 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
2023-06-24  0:01 ` [Bug c/110376] " pinskia at gcc dot gnu.org
2023-07-04 10:32 ` cvs-commit at gcc dot gnu.org
2023-07-04 15:54 ` shaohua.li at inf dot ethz.ch
2023-07-04 17:26 ` pinskia at gcc dot gnu.org
2023-07-05  7:26 ` 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).