Bug 44028 - -fcompare-debug failure (length) with -O3 -fsched-pressure -fschedule-insns
Summary: -fcompare-debug failure (length) with -O3 -fsched-pressure -fschedule-insns
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.5.1
Assignee: Jakub Jelinek
URL:
Keywords: compare-debug-failure
Depends on: 44223
Blocks:
  Show dependency treegraph
 
Reported: 2010-05-07 15:50 UTC by Zdenek Sojka
Modified: 2022-01-18 23:30 UTC (History)
2 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-05-07 17:46:08


Attachments
reduced testcase (from gcc.c-torture/execute/20030914-1.c) (148 bytes, text/plain)
2010-05-07 15:53 UTC, Zdenek Sojka
Details
gcc46-pr44028.patch (844 bytes, patch)
2010-05-10 13:26 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2010-05-07 15:50:53 UTC
Command line:
$ gcc -O1 -fregmove -fsched-pressure -ftree-vectorize -funroll-loops -fschedule-insns -fcompare-debug testcase.c
or
$ gcc -O3 -fsched-pressure -fschedule-insns -fcompare-debug testcase.c

Tested revisions:
r159062 - fail
r159045 - fail
r158683 - fail
r153685 - fail
Comment 1 Zdenek Sojka 2010-05-07 15:53:42 UTC
Created attachment 20597 [details]
reduced testcase (from gcc.c-torture/execute/20030914-1.c)

Different code is generated with x86_64-linux as target
Comment 2 Uroš Bizjak 2010-05-07 17:46:08 UTC
The difference starts in sched1 dumps:

[...]
+{r127:XF=float(r150:SI);clobber [frame:DI-0x44];}
+REG_DEAD: r150:SI
 {r160:HI=r160:HI|0xc00;clobber flags:CC;}
 REG_UNUSED: flags:CC
 r106:XF=r106:XF+r120:XF
 REG_DEAD: r120:XF
-{r127:XF=float(r150:SI);clobber [frame:DI-0x44];}
-REG_DEAD: r150:SI
[...]
Comment 3 Jakub Jelinek 2010-05-07 20:13:22 UTC
Slightly more reduced testcase:

void
foo (unsigned f, long v, unsigned *w, unsigned a, unsigned b, unsigned e, unsigned c, unsigned d)
{
  unsigned h = v / 4, x[16];
  while (f < h)
    {
      unsigned i;
      f++;
      a |= (a >> 30);
      d = (d << 30) | ((unsigned) d >> 30);
      c = (c << 30) | ((unsigned) c >> 30);
      b = 30 | ((unsigned) b >> 30);
      d += a = (a << 30) | ((unsigned) a >> 2);
      c += ((d << 5) | (d >> 27)) + ((e & (a ^ b))) + 0x5a827999 + x[12];
      a += (c & e);
      c = 30 | ((unsigned) c);
      i = x[5] ^ x[7] ^ x[8] ^ x[3];
      x[5] = (i << 1) | ((unsigned) i >> 31);
      i = x[6] ^ x[2] ^ x[14] ^ x[13];
      x[6] = (i << 1) | (i >> 31);
      b += (c | (c >> 5)) + (d ^ e) + 0x6ed9eba1
        + (x[7] = (i << 1) | ((unsigned) i >> 31));
      x[8] = i | 1;
      e += (a | 5) + b + (i = x[9] ^ x[6], x[10] = (i << (unsigned) i));
      e = 30 | ((unsigned) e >> 30);
      i = x[12] ^ x[14] ^ x[12] ^ x[12], (x[12] = 1 | ((unsigned) i));
      i = x[13] ^ x[5] ^ x[10], (x[13] = (i << (unsigned) 1));
      i = x[2] ^ x[7] ^ x[12], (x[15] = i | ((unsigned) i >> 1));
      i = x[2] ^ x[0] ^ x[13], (x[0] = (i << 1) | 31);
      e = (e << 30) | 2;
      i = x[14] ^ x[2] ^ x[15], (x[2] = i | 1);
      x[3] = i | ((unsigned) i);
      i = x[14] ^ x[12] ^ x[4], (x[4] = 1 | ((unsigned) i >> 1));
      x[5] = i | 1;
      e = (e << 30) | 30;
      b += (5 | ((unsigned) e >> 5)) + 0x8f1bbcdc
        + (x[9] = (i | ((unsigned) i >> 1)));
      i = x[2] ^ (x [10] = ((i << 1) | (i >> 1)));
      x[13] = (i | ((unsigned) i >> 1));
      (i = x[14] ^ x[0] ^ x[14], (x[14] = ((i << 1) | 31)));
      a = *w += a;
    }
}
Comment 4 H.J. Lu 2010-05-07 20:14:14 UTC
It is caused by revision 152927:

http://gcc.gnu.org/ml/gcc-cvs/2009-10/msg00580.html
Comment 5 Jakub Jelinek 2010-05-07 20:24:40 UTC
#c3 testcase is actually from PR44023.  Sorry.
Comment 6 Jakub Jelinek 2010-05-10 13:26:55 UTC
Created attachment 20618 [details]
gcc46-pr44028.patch

Untested fix.
Comment 7 Jakub Jelinek 2010-05-10 18:28:20 UTC
Subject: Bug 44028

Author: jakub
Date: Mon May 10 18:28:03 2010
New Revision: 159240

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159240
Log:
	PR debug/44028
	* haifa-sched.c (schedule_insn): When clearing INSN_VAR_LOCATION_LOC,
	clear also INSN_REG_USE_LIST.

	* gcc.dg/pr44028.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr44028.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/haifa-sched.c
    trunk/gcc/testsuite/ChangeLog

Comment 8 Jakub Jelinek 2010-05-10 20:05:29 UTC
Subject: Bug 44028

Author: jakub
Date: Mon May 10 20:05:09 2010
New Revision: 159244

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159244
Log:
	PR debug/44028
	* haifa-sched.c (schedule_insn): When clearing INSN_VAR_LOCATION_LOC,
	clear also INSN_REG_USE_LIST.

	* gcc.dg/pr44028.c: New test.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/pr44028.c
Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/haifa-sched.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog

Comment 9 Jakub Jelinek 2010-05-10 20:15:41 UTC
Fixed.
Comment 10 Jakub Jelinek 2010-05-21 11:22:05 UTC
This change caused by PR44223 regression.