public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/101066] New: Wrong code after fixup_cfg3
@ 2021-06-14 13:45 stefansf at linux dot ibm.com
  2021-06-15  7:02 ` [Bug tree-optimization/101066] [10/11/12 Regression] Wrong code after fixup_cfg3 since r10-3311-gff6686d2e5f797d6 marxin at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: stefansf at linux dot ibm.com @ 2021-06-14 13:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101066
           Summary: Wrong code after fixup_cfg3
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stefansf at linux dot ibm.com
  Target Milestone: ---
            Target: s390*-*-*, x86_64-*-*

int a = 1, c, d, e;
int *b = &a;
static int g(int *h) {
  c = *h;
  return d;
}
static void f(int *h) {
  e = *h;
  *b = 0;
  g(h);
}
int main() {
  f(b);
  printf("%d\n", c);
}

Running `gcc t.c -Os && ./a.out` results in printed 1 whereas 0 is expected.
This does not happen for -O[0,1,2,3] i.e. there 0 is printed.

Prior fixup_cfg3 the code looks good to me and afterwards the assignment to c
uses a cached/initial value of variable a which is wrong:

int main ()
{
  int * b.0_1;
  int c.1_2;
  int _6;
  int _7;
  int * b.2_8;
  int _10;
  int _11;

  <bb 2> [local count: 1073741824]:
  b.0_1 = b;
  _6 = *b.0_1;
  _7 = _6;
  e = _7;
  b.2_8 = b;
  *b.2_8 = 0;
  _10 = _6;
  c = _10;
  _11 = d;
  c.1_2 = c;
  printf ("%d\n", c.1_2);
  return 0;

}

Reproducible on IBM Z as well as x86_64 using commit 831589c227c.

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

end of thread, other threads:[~2021-07-20 12:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14 13:45 [Bug c/101066] New: Wrong code after fixup_cfg3 stefansf at linux dot ibm.com
2021-06-15  7:02 ` [Bug tree-optimization/101066] [10/11/12 Regression] Wrong code after fixup_cfg3 since r10-3311-gff6686d2e5f797d6 marxin at gcc dot gnu.org
2021-06-15  7:51 ` rguenth at gcc dot gnu.org
2021-06-15 17:31 ` jamborm at gcc dot gnu.org
2021-06-21 20:18 ` [Bug ipa/101066] " jamborm at gcc dot gnu.org
2021-06-24 11:42 ` stefansf at linux dot ibm.com
2021-07-08 17:46 ` cvs-commit at gcc dot gnu.org
2021-07-09 14:12 ` cvs-commit at gcc dot gnu.org
2021-07-20 12:30 ` cvs-commit at gcc dot gnu.org
2021-07-20 12:32 ` jamborm 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).