[Bug rtl-optimization/95123] New: [10/11 Regression] Wrong code w/ -O2 -fselective-scheduling2 -funroll-loops --param early-inlining-insns=5 --param loop-invariant-max-bbs-in-loop=3 --param max-jump-thread-duplication-stmts=0

asolokha at gmx dot com gcc-bugzilla@gcc.gnu.org
Thu May 14 08:20:08 GMT 2020


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

            Bug ID: 95123
           Summary: [10/11 Regression] Wrong code w/ -O2
                    -fselective-scheduling2 -funroll-loops --param
                    early-inlining-insns=5 --param
                    loop-invariant-max-bbs-in-loop=3 --param
                    max-jump-thread-duplication-stmts=0
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
  Target Milestone: ---
            Target: x86_64-unknown-linux-gnu

The following program, compiled w/ gcc-11.0.0-alpha20200510 snapshot
(g:13a46321516e2efd3bbb1f1899c539c6724240a9) w/ -O2 -fselective-scheduling2
-funroll-loops --param early-inlining-insns=5 --param
loop-invariant-max-bbs-in-loop=3 --param max-jump-thread-duplication-stmts=0,
segfauls on run-time:

int ak, mt;
const int g5[1] = { -1 }, ip[5] = { 0 };
unsigned int eu;

void
cm (unsigned char t9)
{
  (void) t9;
  eu = (eu & (~0 - 1)) + ip[eu + 1 > 1];
}

void
qe (unsigned int nc)
{
  cm (nc);
  cm (nc);
  cm (nc);
  asm ("");
  cm (nc);
}

int
main (void)
{
  int xh, bc = mt == 2;

  mt = ak;

  for (xh = 0; xh < 1; ++xh)
    {
      qe (g5[xh]);
      asm (";");
      if (!!bc)
        __builtin_puts ("");
    }

  for (xh = 0; xh < 5; ++xh)
    {
      qe (ip[xh]);
      asm (";");
      if (!!bc)
        __builtin_printf ("%d\n", xh);

    }

  for (xh = 0; xh < 3; ++xh)
    {
      qe (ip[xh]);
      if (!!bc)
        mt += xh;
    }

  return 0;
}

% x86_64-unknown-linux-gnu-gcc-11.0.0 -O2 -fselective-scheduling2 --param
early-inlining-insns=5 --param loop-invariant-max-bbs-in-loop=3 --param
max-jump-thread-duplication-stmts=0 -o good cd8zuepp.c
% ./good
% echo $?
0

% x86_64-unknown-linux-gnu-gcc-11.0.0 -O2 -fselective-scheduling2
-funroll-loops --param early-inlining-insns=5 --param
loop-invariant-max-bbs-in-loop=3 --param max-jump-thread-duplication-stmts=0 -o
bad cd8zuepp.c
% ./bad 
zsh: segmentation fault (core dumped)  ./bad


More information about the Gcc-bugs mailing list