Bug 43012 - [4.5 Regression][graphite] wrong code for -floop-strip-mine in 453.povray
Summary: [4.5 Regression][graphite] wrong code for -floop-strip-mine in 453.povray
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.5.0
: P1 normal
Target Milestone: 4.5.0
Assignee: Sebastian Pop
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2010-02-09 21:27 UTC by Janis Johnson
Modified: 2010-02-12 14:54 UTC (History)
3 users (show)

See Also:
Host:
Target: powerpc64-linux
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-02-11 19:16:21


Attachments
minimized executable testcase (401 bytes, text/plain)
2010-02-09 21:29 UTC, Janis Johnson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Janis Johnson 2010-02-09 21:27:46 UTC
SPEC CPU2006 test 453.povray is miscompiled by GCC mainline on powerpc64-linux for "-O2 -floop-strip-line" with either -m32 or -m64.  Here's the function that is miscompiled; I'll attach a complete executable testcase:

----------------------------------------------------
void
pre_init_tokenizer ()
{
  int i;

  for (i = 0; i < LAST_TOKEN; i++)
    {
      Table[i] = i;
      if (i < FLOAT_FUNCT_TOKEN)
        Table[i] = FLOAT_FUNCT_TOKEN;
      else
        {
          if (i < VECTOR_FUNCT_TOKEN)
            Table[i] = VECTOR_FUNCT_TOKEN;
          else
            {
              if (i < COLOUR_KEY_TOKEN)
                Table[i] = COLOUR_KEY_TOKEN;
            }
        }
    }
}
----------------------------------------------------

Array elements 51-63 and 89-101 are not assigned values when the code is compiled with "-O2 -floop-strip-mine".

The testcase (and 453.povray) work with GCC 4.4.2 with those options, so this is a regression in GCC 4.5.  The failure starts with this patch:

    http://gcc.gnu.org/viewcvs?view=rev&rev=154637

    r154637 | spop | 2009-11-25 05:30:35 +0000 (Wed, 25 Nov 2009)
Comment 1 Janis Johnson 2010-02-09 21:29:37 UTC
Created attachment 19832 [details]
minimized executable testcase
Comment 2 Alexander Monakov 2010-02-10 18:41:13 UTC
Confirming. Reproducible on amd64-linux.

This appears to be a bug in CLooG.  Disable CLooG optimizations on graphite branch fixes the bug.  The problem is that CLooG generates wrong bounds for parts of strip-mined loop (bounds of the first and the last loops are wrong):

for (scat_3=-51;scat_3<=63;scat_3++) {
  S3(scat_3) ;
  S4(scat_3) ;
}
for (scat_3=64;scat_3<=76;scat_3++) {
  S3(scat_3) ;
  S6(scat_3) ;
}
for (scat_3=77;scat_3<=88;scat_3++) {
  S3(scat_3) ;
  S8(scat_3) ;
}
for (scat_3=89;scat_3<=-1;scat_3++) {
  S3(scat_3) ;
}
Comment 3 Alexander Monakov 2010-02-11 14:28:29 UTC
(In reply to comment #2)
> Confirming. Reproducible on amd64-linux.
> 
> This appears to be a bug in CLooG.  Disable CLooG optimizations on graphite
> branch fixes the bug.  The problem is that CLooG generates wrong bounds for
> parts of strip-mined loop (bounds of the first and the last loops are wrong):

I've sent a CLooG patch.
Comment 4 Richard Biener 2010-02-11 16:54:37 UTC
Thus we need a patched CLooG in the infrastructure for 4.5.
Comment 5 Sebastian Pop 2010-02-11 17:11:21 UTC
Yes, I'm preparing another release of CLooG-PPL today.

Sebastian
Comment 6 Sebastian Pop 2010-02-11 19:16:21 UTC
You can get the new CLooG-PPL 0.15.8 from
ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-ppl-0.15.8.tar.gz
I will commit the testcase to the Graphite testsuite, and then I will close this bug.
Comment 7 Sebastian Pop 2010-02-11 19:19:52 UTC
Subject: Bug 43012

Author: spop
Date: Thu Feb 11 19:19:37 2010
New Revision: 156708

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

2010-02-11  Sebastian Pop  <sebastian.pop@amd.com>

	PR middle-end/43012
	* gcc.dg/graphite/pr43012.c: New.

Added:
    branches/graphite/gcc/testsuite/gcc.dg/graphite/pr43012.c
Modified:
    branches/graphite/gcc/ChangeLog.graphite

Comment 8 Sebastian Pop 2010-02-11 19:43:44 UTC
Subject: Bug 43012

Author: spop
Date: Thu Feb 11 19:43:14 2010
New Revision: 156716

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

2010-02-11  Sebastian Pop  <sebastian.pop@amd.com>

	PR middle-end/43012
	* gcc.dg/graphite/pr43012.c: New.

Added:
    trunk/gcc/testsuite/gcc.dg/graphite/pr43012.c
Modified:
    trunk/gcc/ChangeLog.graphite

Comment 9 Sebastian Pop 2010-02-11 19:49:18 UTC
Fixed.
Comment 10 H.J. Lu 2010-02-12 01:18:12 UTC
It failed at run-time on Linux/ia32:

FAIL: gcc.dg/graphite/pr43012.c execution test
Comment 11 Sebastian Pop 2010-02-12 14:54:15 UTC
You need to upgrade your CLooG-PPL to 0.15.8 for this testcase to not fail. 
I've put a comment in the testcase itself for this.

ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-ppl-0.15.8.tar.gz

Sebastian