public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/66652] try_transform_to_exit_first_loop_alt generates incorrect loop
       [not found] <bug-66652-4@http.gcc.gnu.org/bugzilla/>
@ 2015-06-25 12:37 ` vries at gcc dot gnu.org
  2015-06-27  5:52 ` vries at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2015-06-25 12:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from vries at gcc dot gnu.org ---
Created attachment 35853
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35853&action=edit
demonstrator patch

This patch fixes the correctness issue, but it fails to do
transform_to_exit_first_loop_alt for unsigned loop counters:
...
PASS: gcc.dg/parloops-exit-first-loop-alt-2.c (test for excess errors)
PASS: gcc.dg/parloops-exit-first-loop-alt-2.c scan-tree-dump-times parloops
"(?n)\\[i" 9
PASS: gcc.dg/parloops-exit-first-loop-alt-3.c (test for excess errors)
FAIL: gcc.dg/parloops-exit-first-loop-alt-3.c scan-tree-dump-times parloops
"(?n)\\* 4" 3
PASS: gcc.dg/parloops-exit-first-loop-alt-4.c (test for excess errors)
PASS: gcc.dg/parloops-exit-first-loop-alt-4.c scan-tree-dump-times parloops
"(?n)\\* 4" 3
PASS: gcc.dg/parloops-exit-first-loop-alt-5.c (test for excess errors)
PASS: gcc.dg/parloops-exit-first-loop-alt-5.c scan-tree-dump-times parloops
"(?n)% 13" 4
PASS: gcc.dg/parloops-exit-first-loop-alt-6.c (test for excess errors)
FAIL: gcc.dg/parloops-exit-first-loop-alt-6.c scan-tree-dump-times parloops
"(?n)\\[i" 9
PASS: gcc.dg/parloops-exit-first-loop-alt-7.c (test for excess errors)
FAIL: gcc.dg/parloops-exit-first-loop-alt-7.c scan-tree-dump-times parloops
"(?n)\\[i" 9
PASS: gcc.dg/parloops-exit-first-loop-alt-8.c (test for excess errors)
FAIL: gcc.dg/parloops-exit-first-loop-alt-8.c scan-tree-dump-times parloops
"(?n)\\[i" 9
PASS: gcc.dg/parloops-exit-first-loop-alt.c (test for excess errors)
FAIL: gcc.dg/parloops-exit-first-loop-alt.c scan-tree-dump-times parloops
"(?n)\\[i" 9
...


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

* [Bug tree-optimization/66652] try_transform_to_exit_first_loop_alt generates incorrect loop
       [not found] <bug-66652-4@http.gcc.gnu.org/bugzilla/>
  2015-06-25 12:37 ` [Bug tree-optimization/66652] try_transform_to_exit_first_loop_alt generates incorrect loop vries at gcc dot gnu.org
@ 2015-06-27  5:52 ` vries at gcc dot gnu.org
  2015-06-29 11:41 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2015-06-27  5:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from vries at gcc dot gnu.org ---
Created attachment 35865
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35865&action=edit
follow-up patch for demonstrator patch

This patch in addition allows transform_to_exit_first_loop_alt for unsigned
loop counters. But it's not generic enough to also handle the fortran testcases
in https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01234.html .

For parloops-exit-first-loop-alt.f95, we have:
...
foo (integer(kind=4)D.8 & restrict nrD.3381)
{
  integer(kind=4) ii;
  integer(kind=4) _6;
  integer(kind=4) _7;
  integer(kind=8) _8;
  integer(kind=4) _9;
  integer(kind=4) _10;
  integer(kind=4) _11;
  integer(kind=4) _12;
  integer(kind=4) _13;
  integer(kind=8) _16;
  unsigned int _19;
  integer(kind=4) _20;
  integer(kind=4) _22;
  integer(kind=4) _23;
  integer(kind=4) _24;
  signed int ivtmp_27;
  signed int ivtmp_28;

  <bb 2>:
  _6 = *nr_5(D);
  _7 = _6 + -1;
  if (_7 >= 0)
    goto <bb 4>;
  else
    goto <bb 3>;

  <bb 3>:
  return;

  <bb 4>:
  _20 = _6 + -1;
  _19 = (unsigned int) _20;

  <bb 10>:
  if (_19 > 199)
    goto <bb 11>;
  else
    goto <bb 12>;

  <bb 11>:

  <bb 5>:
  # ivtmp_27 = PHI <0(11), ivtmp_28(7)>
  ii_1 = ivtmp_27;
  _8 = (integer(kind=8)) ii_1;
  _9 = __BLNK__.a[_8];
  _11 = __BLNK__.b[_8];
  _12 = _9 + _11;
  _13 = _12 + 25;
  __BLNK__.c[_8] = _13;
  ii_15 = ii_1 + 1;
  if (ivtmp_27 < _19)
    goto <bb 7>;
  else
    goto <bb 6>;

  <bb 6>:
  goto <bb 3>;

  <bb 7>:
  ivtmp_28 = ivtmp_27 + 1;
  goto <bb 5>;

  <bb 12>:

  <bb 8>:
  # ii_18 = PHI <0(12), ii_26(9)>
  _16 = (integer(kind=8)) ii_18;
  _10 = __BLNK__.a[_16];
  _23 = __BLNK__.b[_16];
  _22 = _10 + _23;
  _24 = _22 + 25;
  __BLNK__.c[_16] = _24;
  ii_26 = ii_18 + 1;
  if (ii_18 == _7)
    goto <bb 6>;
  else
    goto <bb 9>;

  <bb 9>:
  goto <bb 8>;

}
...

the nit is _19:
...
  _20 = _6 + -1;
  _19 = (unsigned int) _20;
...


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

* [Bug tree-optimization/66652] try_transform_to_exit_first_loop_alt generates incorrect loop
       [not found] <bug-66652-4@http.gcc.gnu.org/bugzilla/>
  2015-06-25 12:37 ` [Bug tree-optimization/66652] try_transform_to_exit_first_loop_alt generates incorrect loop vries at gcc dot gnu.org
  2015-06-27  5:52 ` vries at gcc dot gnu.org
@ 2015-06-29 11:41 ` vries at gcc dot gnu.org
  2015-06-29 14:41 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2015-06-29 11:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from vries at gcc dot gnu.org ---
Created attachment 35873
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35873&action=edit
tentative patch

currently doing bootstrap and reg-test on x86_64.


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

* [Bug tree-optimization/66652] try_transform_to_exit_first_loop_alt generates incorrect loop
       [not found] <bug-66652-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2015-06-29 11:41 ` vries at gcc dot gnu.org
@ 2015-06-29 14:41 ` vries at gcc dot gnu.org
  2015-06-30  8:36 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2015-06-29 14:41 UTC (permalink / raw)
  To: gcc-bugs

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

vries at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, wrong-code

--- Comment #4 from vries at gcc dot gnu.org ---
https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02084.html


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

* [Bug tree-optimization/66652] try_transform_to_exit_first_loop_alt generates incorrect loop
       [not found] <bug-66652-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2015-06-29 14:41 ` vries at gcc dot gnu.org
@ 2015-06-30  8:36 ` vries at gcc dot gnu.org
  2015-06-30  8:39 ` vries at gcc dot gnu.org
  2015-06-30  9:58 ` vries at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2015-06-30  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from vries at gcc dot gnu.org ---
Author: vries
Date: Tue Jun 30 08:35:57 2015
New Revision: 225162

URL: https://gcc.gnu.org/viewcvs?rev=225162&root=gcc&view=rev
Log:
Use max_loop_iterations in transform_to_exit_first_loop_alt

2015-06-30  Tom de Vries  <tom@codesourcery.com>

        PR tree-optimization/66652
        * tree-parloops.c (try_transform_to_exit_first_loop_alt): Use
        max_loop_iterations to determine if nit + 1 overflows.

        * testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c (f): Rewrite
        using restrict pointers.
        (main): Add arguments to calls to f.
        * testsuite/libgomp.c/parloops-exit-first-loop-alt.c: Same.

        * gcc.dg/parloops-exit-first-loop-alt-pr66652.c: New test.
        * gcc.dg/parloops-exit-first-loop-alt-3.c (f):  Rewrite using restrict
        pointers.
        * gcc.dg/parloops-exit-first-loop-alt.c: Same.

Added:
    trunk/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-pr66652.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-3.c
    trunk/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c
    trunk/gcc/tree-parloops.c
    trunk/libgomp/ChangeLog
    trunk/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c
    trunk/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c


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

* [Bug tree-optimization/66652] try_transform_to_exit_first_loop_alt generates incorrect loop
       [not found] <bug-66652-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2015-06-30  8:36 ` vries at gcc dot gnu.org
@ 2015-06-30  8:39 ` vries at gcc dot gnu.org
  2015-06-30  9:58 ` vries at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2015-06-30  8:39 UTC (permalink / raw)
  To: gcc-bugs

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

vries at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |vries at gcc dot gnu.org

--- Comment #6 from vries at gcc dot gnu.org ---
Patch with test-case committed to trunk, marking resolved-fixed.


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

* [Bug tree-optimization/66652] try_transform_to_exit_first_loop_alt generates incorrect loop
       [not found] <bug-66652-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2015-06-30  8:39 ` vries at gcc dot gnu.org
@ 2015-06-30  9:58 ` vries at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2015-06-30  9:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from vries at gcc dot gnu.org ---
Author: vries
Date: Tue Jun 30 09:57:20 2015
New Revision: 225166

URL: https://gcc.gnu.org/viewcvs?rev=225166&root=gcc&view=rev
Log:
Backport transform_to_exit_first_loop_alt-related patches

2015-06-30  Tom de Vries  <tom@codesourcery.com>

        backport from trunk:
        2015-06-30  Tom de Vries  <tom@codesourcery.com>

        PR tree-optimization/66652
        * tree-parloops.c (try_transform_to_exit_first_loop_alt): Use
        max_loop_iterations to determine if nit + 1 overflows.

        * testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c (f): Rewrite
        using restrict pointers.
        (main): Add arguments to calls to f.
        * testsuite/libgomp.c/parloops-exit-first-loop-alt.c: Same.

        * gcc.dg/parloops-exit-first-loop-alt-pr66652.c: New test.
        * gcc.dg/parloops-exit-first-loop-alt-3.c (f):  Rewrite using restrict
        pointers.
        * gcc.dg/parloops-exit-first-loop-alt.c: Same.

        2015-06-29  Tom de Vries  <tom@codesourcery.com>

        * tree-parloops.c (try_transform_to_exit_first_loop_alt): Simplify
        function structure.

        2015-06-23  Tom de Vries  <tom@codesourcery.com>

        * testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c (main): Use
        abort.
        * testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c (main): Same.

        2015-06-22  Tom de Vries  <tom@codesourcery.com>

        * tree-parloops.c (transform_to_exit_first_loop_alt): Add update_stmt
        for cond_stmt.

        2015-06-13  Tom de Vries  <tom@codesourcery.com>

        * gcc.dg/parloops-exit-first-loop-alt-4.c: New test.

        * testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c: New test.

        * testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c: Add comment.
        * testsuite/libgomp.c/parloops-exit-first-loop-alt.c: Same.
        * testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c: Add comment.
        (N): Define.
        (main): Use N instead of hardcoded constants.

        * gcc.dg/parloops-exit-first-loop-alt-2.c: Add comment.
        (main): Remove superfluous attributes.
        * gcc.dg/parloops-exit-first-loop-alt-3.c: Same.
        * gcc.dg/parloops-exit-first-loop-alt.c: Same.

Added:
   
branches/gomp-4_0-branch/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-4.c
      - copied, changed from r225165,
branches/gomp-4_0-branch/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-3.c
   
branches/gomp-4_0-branch/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-pr66652.c
   
branches/gomp-4_0-branch/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c
      - copied, changed from r225165,
branches/gomp-4_0-branch/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c
Modified:
    branches/gomp-4_0-branch/gcc/ChangeLog.gomp
    branches/gomp-4_0-branch/gcc/testsuite/ChangeLog.gomp
   
branches/gomp-4_0-branch/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-2.c
   
branches/gomp-4_0-branch/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-3.c
   
branches/gomp-4_0-branch/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c
    branches/gomp-4_0-branch/gcc/tree-parloops.c
    branches/gomp-4_0-branch/libgomp/ChangeLog.gomp
   
branches/gomp-4_0-branch/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c
   
branches/gomp-4_0-branch/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c
   
branches/gomp-4_0-branch/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c


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

end of thread, other threads:[~2015-06-30  9:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-66652-4@http.gcc.gnu.org/bugzilla/>
2015-06-25 12:37 ` [Bug tree-optimization/66652] try_transform_to_exit_first_loop_alt generates incorrect loop vries at gcc dot gnu.org
2015-06-27  5:52 ` vries at gcc dot gnu.org
2015-06-29 11:41 ` vries at gcc dot gnu.org
2015-06-29 14:41 ` vries at gcc dot gnu.org
2015-06-30  8:36 ` vries at gcc dot gnu.org
2015-06-30  8:39 ` vries at gcc dot gnu.org
2015-06-30  9:58 ` vries 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).