public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/54634] New: [4.8 Regression] miscompilation with -O3  -ftree-loop-distribution
@ 2012-09-20  8:55 Joost.VandeVondele at mat dot ethz.ch
  2012-09-20  8:58 ` [Bug tree-optimization/54634] " jakub at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Joost.VandeVondele at mat dot ethz.ch @ 2012-09-20  8:55 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54634

             Bug #: 54634
           Summary: [4.8 Regression] miscompilation with -O3
                    -ftree-loop-distribution
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: Joost.VandeVondele@mat.ethz.ch


Created attachment 28227
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28227
testcase sources

The attached sources are miscompiled with current trunk ([trunk revision
191430]) at -O3  -ftree-loop-distribution. To reproduce 

gfortran -O3  -ftree-loop-distribution  -ffree-form other.F mathconstants.F
orbital_pointers.F orbital_symbols.F orbital_transformation_matrices.F main.F ;
./a.out

which outputs wrong values (as compared to -O0) and shows a valgrind warning
(not present at -O0).

The miscompiled file is orbital_transformation_matrices.F, most likely the
routine create_spherical_harmonics (which seems inlined). If I cat at files in
a single .F file, the error also disappears, which might hint at some ipa thing
?

4.7 branch ([gcc-4_7-branch revision 190437]) is doing fine.


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

* [Bug tree-optimization/54634] [4.8 Regression] miscompilation with -O3  -ftree-loop-distribution
  2012-09-20  8:55 [Bug tree-optimization/54634] New: [4.8 Regression] miscompilation with -O3 -ftree-loop-distribution Joost.VandeVondele at mat dot ethz.ch
@ 2012-09-20  8:58 ` jakub at gcc dot gnu.org
  2012-09-20 10:17 ` Joost.VandeVondele at mat dot ethz.ch
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-09-20  8:58 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54634

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-09-20 08:58:02 UTC ---
Retry with PR54629 fix?


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

* [Bug tree-optimization/54634] [4.8 Regression] miscompilation with -O3  -ftree-loop-distribution
  2012-09-20  8:55 [Bug tree-optimization/54634] New: [4.8 Regression] miscompilation with -O3 -ftree-loop-distribution Joost.VandeVondele at mat dot ethz.ch
  2012-09-20  8:58 ` [Bug tree-optimization/54634] " jakub at gcc dot gnu.org
@ 2012-09-20 10:17 ` Joost.VandeVondele at mat dot ethz.ch
  2012-09-20 11:30 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Joost.VandeVondele at mat dot ethz.ch @ 2012-09-20 10:17 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54634

--- Comment #2 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> 2012-09-20 10:15:57 UTC ---
(In reply to comment #1)
> Retry with PR54629 fix?

after applying the patch mentioned above, the testcase still fails. The failure
is also older than the commit mentioned in PR54629


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

* [Bug tree-optimization/54634] [4.8 Regression] miscompilation with -O3  -ftree-loop-distribution
  2012-09-20  8:55 [Bug tree-optimization/54634] New: [4.8 Regression] miscompilation with -O3 -ftree-loop-distribution Joost.VandeVondele at mat dot ethz.ch
  2012-09-20  8:58 ` [Bug tree-optimization/54634] " jakub at gcc dot gnu.org
  2012-09-20 10:17 ` Joost.VandeVondele at mat dot ethz.ch
@ 2012-09-20 11:30 ` rguenth at gcc dot gnu.org
  2012-09-20 12:27 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-09-20 11:30 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54634

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-09-20
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |
   Target Milestone|---                         |4.8.0
     Ever Confirmed|0                           |1

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-09-20 11:29:51 UTC ---
Mine.


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

* [Bug tree-optimization/54634] [4.8 Regression] miscompilation with -O3  -ftree-loop-distribution
  2012-09-20  8:55 [Bug tree-optimization/54634] New: [4.8 Regression] miscompilation with -O3 -ftree-loop-distribution Joost.VandeVondele at mat dot ethz.ch
                   ` (2 preceding siblings ...)
  2012-09-20 11:30 ` rguenth at gcc dot gnu.org
@ 2012-09-20 12:27 ` rguenth at gcc dot gnu.org
  2012-09-20 13:07 ` Joost.VandeVondele at mat dot ethz.ch
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-09-20 12:27 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54634

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-09-20 12:26:53 UTC ---
We split

  <bb 89>:
  # s2_207 = PHI <0.0(88), s2_524(91)>
  # prephitmp_1456 = PHI <0(88), k.76_530(91)>
  _496 = prephitmp_1456 * -2;
  _1535 = lx_355 + _496;
  D.3330 = _1535;
  _1533 = binomial (&j, &k);
  _517 = binomial (&ma, &D.3330);
  _518 = _1533 * _517;
  _520 = _518 * 0.0;
  s2_524 = _520 + s2_207;
  D.3330 ={v} {CLOBBER};
  k.76_530 = prephitmp_1456 + 1;
  k = k.76_530;
  if (j.72_383 == prephitmp_1456)
    goto <bb 90>;
  else
    goto <bb 91>;

into bogus pieces:

  <bb 204>:
  # prephitmp_1664 = PHI <k.76_1674(205), 0(88)>
  _1665 = prephitmp_1664 * -2;
  _1666 = lx_355 + _1665;
  D.3330 = _1666;
  D.3330 ={v} {CLOBBER};
  k.76_1674 = prephitmp_1664 + 1;
  if (j.72_383 == prephitmp_1664)
    goto <bb 206>;
  else
    goto <bb 205>;

split for the store D.3330 (huh, well ...), but somehow lost the
binomial call here.

  <bb 207>:
  # prephitmp_1678 = PHI <k.76_1688(208), 0(206)>
  k.76_1688 = prephitmp_1678 + 1;
  k = k.76_1688;
  if (j.72_383 == prephitmp_1678)
    goto <bb 209>;
  else
    goto <bb 208>;

well ... likewise.

  <bb 89>:
  # s2_207 = PHI <0.0(209), s2_524(91)>
  # prephitmp_1456 = PHI <0(209), k.76_530(91)>
  _1533 = binomial (&j, &k);
  _517 = binomial (&ma, &D.3330);
  _518 = _1533 * _517;
  _520 = _518 * 0.0;
  s2_524 = _520 + s2_207;
  k.76_530 = prephitmp_1456 + 1;
  if (j.72_383 == prephitmp_1456)
    goto <bb 90>;
  else
    goto <bb 91>;

finally all the calls.  Investigating some more.

Ah, binomial () is pure.  The RDG is bogus, it does not consider
calls that merely read unknown memory.  That is because
get_references_in_stmt handles calls by returning true/false only ...
in this case it doesn't add any data references.

So it's a very old problem that bites us now.

*sigh*


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

* [Bug tree-optimization/54634] [4.8 Regression] miscompilation with -O3  -ftree-loop-distribution
  2012-09-20  8:55 [Bug tree-optimization/54634] New: [4.8 Regression] miscompilation with -O3 -ftree-loop-distribution Joost.VandeVondele at mat dot ethz.ch
                   ` (3 preceding siblings ...)
  2012-09-20 12:27 ` rguenth at gcc dot gnu.org
@ 2012-09-20 13:07 ` Joost.VandeVondele at mat dot ethz.ch
  2012-09-20 13:44 ` rguenther at suse dot de
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Joost.VandeVondele at mat dot ethz.ch @ 2012-09-20 13:07 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54634

--- Comment #5 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> 2012-09-20 13:06:50 UTC ---
(In reply to comment #4)
> Ah, binomial () is pure.

In this case, it was presumably triggered by Tobias' changes for PR54389.
binomial() has not been declared pure in the source, but most likely correctly
declared 'implicitly pure' but the Fortran frontend.


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

* [Bug tree-optimization/54634] [4.8 Regression] miscompilation with -O3  -ftree-loop-distribution
  2012-09-20  8:55 [Bug tree-optimization/54634] New: [4.8 Regression] miscompilation with -O3 -ftree-loop-distribution Joost.VandeVondele at mat dot ethz.ch
                   ` (4 preceding siblings ...)
  2012-09-20 13:07 ` Joost.VandeVondele at mat dot ethz.ch
@ 2012-09-20 13:44 ` rguenther at suse dot de
  2012-09-20 14:47 ` rguenth at gcc dot gnu.org
  2012-09-20 14:49 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenther at suse dot de @ 2012-09-20 13:44 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54634

--- Comment #6 from rguenther at suse dot de <rguenther at suse dot de> 2012-09-20 13:43:33 UTC ---
On Thu, 20 Sep 2012, Joost.VandeVondele at mat dot ethz.ch wrote:

> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54634
> 
> --- Comment #5 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> 2012-09-20 13:06:50 UTC ---
> (In reply to comment #4)
> > Ah, binomial () is pure.
> 
> In this case, it was presumably triggered by Tobias' changes for PR54389.
> binomial() has not been declared pure in the source, but most likely correctly
> declared 'implicitly pure' but the Fortran frontend.

Btw, it's just what triggers the latent bug in data dependence analysis.
I am testing

Index: gcc/tree-data-ref.c
===================================================================
--- gcc/tree-data-ref.c (revision 191561)
+++ gcc/tree-data-ref.c (working copy)
@@ -4307,10 +4307,10 @@ get_references_in_stmt (gimple stmt, VEC
   *references = NULL;

   /* ASM_EXPR and CALL_EXPR may embed arbitrary side effects.
-     Calls have side-effects, except those to const or pure
-     functions.  */
+     As we cannot model data-references to not spelled out
+     accesses give up if they may occur.  */
   if ((stmt_code == GIMPLE_CALL
-       && !(gimple_call_flags (stmt) & (ECF_CONST | ECF_PURE)))
+       && !(gimple_call_flags (stmt) & ECF_CONST))
       || (stmt_code == GIMPLE_ASM
          && (gimple_asm_volatile_p (stmt) || gimple_vuse (stmt))))
     clobbers_memory = true;

currently.


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

* [Bug tree-optimization/54634] [4.8 Regression] miscompilation with -O3  -ftree-loop-distribution
  2012-09-20  8:55 [Bug tree-optimization/54634] New: [4.8 Regression] miscompilation with -O3 -ftree-loop-distribution Joost.VandeVondele at mat dot ethz.ch
                   ` (5 preceding siblings ...)
  2012-09-20 13:44 ` rguenther at suse dot de
@ 2012-09-20 14:47 ` rguenth at gcc dot gnu.org
  2012-09-20 14:49 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-09-20 14:47 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54634

--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-09-20 14:46:41 UTC ---
Author: rguenth
Date: Thu Sep 20 14:46:32 2012
New Revision: 191567

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191567
Log:
2012-09-20  Richard Guenther  <rguenther@suse.de>

    PR tree-optimization/54634
    * tree-data-ref.c (get_references_in_stmt): For now give
    up for pure functions.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-data-ref.c


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

* [Bug tree-optimization/54634] [4.8 Regression] miscompilation with -O3  -ftree-loop-distribution
  2012-09-20  8:55 [Bug tree-optimization/54634] New: [4.8 Regression] miscompilation with -O3 -ftree-loop-distribution Joost.VandeVondele at mat dot ethz.ch
                   ` (6 preceding siblings ...)
  2012-09-20 14:47 ` rguenth at gcc dot gnu.org
@ 2012-09-20 14:49 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-09-20 14:49 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54634

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #8 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-09-20 14:48:57 UTC ---
Fixed.


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

end of thread, other threads:[~2012-09-20 14:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-20  8:55 [Bug tree-optimization/54634] New: [4.8 Regression] miscompilation with -O3 -ftree-loop-distribution Joost.VandeVondele at mat dot ethz.ch
2012-09-20  8:58 ` [Bug tree-optimization/54634] " jakub at gcc dot gnu.org
2012-09-20 10:17 ` Joost.VandeVondele at mat dot ethz.ch
2012-09-20 11:30 ` rguenth at gcc dot gnu.org
2012-09-20 12:27 ` rguenth at gcc dot gnu.org
2012-09-20 13:07 ` Joost.VandeVondele at mat dot ethz.ch
2012-09-20 13:44 ` rguenther at suse dot de
2012-09-20 14:47 ` rguenth at gcc dot gnu.org
2012-09-20 14:49 ` rguenth 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).