Bug 43657 - [4.3/4.4/4.5/4.6 Regression] -ftree-loop-linear causes FAIL: gcc.dg/vect/vect-cond-5.c execution test
Summary: [4.3/4.4/4.5/4.6 Regression] -ftree-loop-linear causes FAIL: gcc.dg/vect/vect...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.5.0
: P2 normal
Target Milestone: 4.3.6
Assignee: Sebastian Pop
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2010-04-05 23:00 UTC by Zdenek Sojka
Modified: 2011-02-02 17:48 UTC (History)
4 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work: 4.1.2, 4.2.4
Known to fail: 4.3.4, 4.4.3, 4.5.0
Last reconfirmed: 2011-01-16 11:50:32


Attachments
slightly reduced testcase, showing computed data (388 bytes, text/plain)
2010-04-05 23:02 UTC, Zdenek Sojka
Details
pr43657.c (374 bytes, text/plain)
2010-05-26 11:15 UTC, Jakub Jelinek
Details
Proposed patch (713 bytes, patch)
2011-01-16 12:29 UTC, Alexandre Oliva
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2010-04-05 23:00:00 UTC
Compiler output:
$ gcc -O1 -ftree-loop-linear vect-cond-5.c && ./a.out
Aborted

Tested revisions:
r157985 - fail
4.4.3, 4.3.4 - fail
4.2.4, 4.1.2 - OK
Comment 1 Zdenek Sojka 2010-04-05 23:02:37 UTC
Created attachment 20319 [details]
slightly reduced testcase, showing computed data

$ gcc-4.5.0-alpha20100401 -O1 -ftree-loop-linear pr43657.c && ./a.out
0 6 2
1 5 2
2 4 2
3 3 2
4 2 2
5 0 0
6 0 0
7 0 0
8 0 0
9 0 0
10 0 0
11 0 0
12 0 0
13 0 0
14 0 0
15 0 0
16 0 0
17 0 0
18 0 0
19 0 0
20 0 0
21 0 0
22 0 0
23 0 0
24 0 0
25 0 0
26 0 0
27 0 0
28 0 0
29 0 0
30 0 0
31 0 0
Aborted

$ gcc-4.2.4 -O1 -ftree-loop-linear pr43657.c && ./a.out
0 2 2
1 2 2
2 2 2
3 2 2
4 2 2
5 0 0
6 0 0
7 0 0
8 0 0
9 0 0
10 0 0
11 0 0
12 0 0
13 0 0
14 0 0
15 0 0
16 0 0
17 0 0
18 0 0
19 0 0
20 0 0
21 0 0
22 0 0
23 0 0
24 0 0
25 0 0
26 0 0
27 0 0
28 0 0
29 0 0
30 0 0
31 0 0
Comment 2 Richard Biener 2010-05-22 18:13:59 UTC
GCC 4.3.5 is being released, adjusting target milestone.
Comment 3 Jakub Jelinek 2010-05-26 11:15:37 UTC
Created attachment 20748 [details]
pr43657.c

Slightly adjusted testcase.
Comment 4 Changpeng Fang 2010-10-19 21:27:46 UTC
 for (k = 0; k < 32; k++)
    {
      res = 0;
      for (j = 0; j < 32; j++) 
        for (i = 0; i < 32; i++)
          { 
            next = a[i][j]; 
            res = c > cond_array[i+k][j] ? next : res;
          }
 
      out[k] = res;
    }


gcc interchanges i and j loops, which is not legal in this case.
Apparently, res takes the last value of a[i][j] that satisfies the 
condition c > cond_array[i+k][j]. As a result, change in the 
reference order will get a different value for res.

Anyone knows where to do this legality check?

What about the interchange in Graphite for this case?
Comment 5 Alexandre Oliva 2011-01-16 11:50:32 UTC
Been looking into this.  There doesn't seem to be anything to prevent the loop from being transformed when an SSA DEF escapes the loop.  Trying to fix.
Comment 6 Alexandre Oliva 2011-01-16 12:29:18 UTC
Created attachment 22982 [details]
Proposed patch

This avoids the transformation, but...  Is the test too strict?  My reasoning is that, since we're in closed form (right?), the exit block will only have PHIs for stuff that is changed wthin the loop and is used outside the loop.  Does that sound sound? :-)
Comment 7 Sebastian Pop 2011-01-18 20:54:38 UTC
Author: spop
Date: Tue Jan 18 20:54:34 2011
New Revision: 168964

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168964
Log:
Add testcase for PR43657.

2011-01-18  Sebastian Pop  <sebastian.pop@amd.com>

	PR tree-optimization/43657
	* gcc.dg/graphite/pr43657.c: New.

Added:
    branches/graphite/gcc/testsuite/gcc.dg/graphite/pr43657.c
Modified:
    branches/graphite/gcc/ChangeLog.graphite
Comment 8 Sebastian Pop 2011-01-18 20:55:48 UTC
Fixed on the graphite branch.
Comment 9 Sebastian Pop 2011-01-25 21:25:05 UTC
Author: spop
Date: Tue Jan 25 21:24:53 2011
New Revision: 169254

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169254
Log:
Add testcase for PR43657.

2011-01-18  Sebastian Pop  <sebastian.pop@amd.com>

	PR tree-optimization/43657
	* gcc.dg/graphite/pr43657.c: New.

Added:
    trunk/gcc/testsuite/gcc.dg/graphite/pr43657.c
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 10 Sebastian Pop 2011-01-25 21:28:55 UTC
Fixed.
Comment 11 Diego Novillo 2011-02-02 17:48:23 UTC
Author: dnovillo
Date: Wed Feb  2 17:48:17 2011
New Revision: 169593

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169593
Log:
Add testcase for PR43657.

2011-01-18  Sebastian Pop  <sebastian.pop@amd.com>

	PR tree-optimization/43657
	* gcc.dg/graphite/pr43657.c: New.

Added:
    branches/google/integration/gcc/testsuite/gcc.dg/graphite/pr43657.c
Modified:
    branches/google/integration/gcc/testsuite/ChangeLog