public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/66975] New: parloops to handle signed int reductions
@ 2015-07-23 12:35 vries at gcc dot gnu.org
  2015-07-26 17:54 ` [Bug tree-optimization/66975] " vries at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2015-07-23 12:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66975
           Summary: parloops to handle signed int reductions
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

With this ( https://gcc.gnu.org/ml/gcc-cvs/2015-07/msg00896.html ) fix we
introduce xfails for signed int reductions:
...
        * gcc.dg/autopar/outer-4.c: Add xfail.
        * gcc.dg/autopar/outer-5.c: Same.
        * gcc.dg/autopar/outer-6.c: Same.
        * gcc.dg/autopar/reduc-2.c: Same.
        * gcc.dg/autopar/reduc-2char.c: Same.
        * gcc.dg/autopar/reduc-2short.c: Same.
        * gcc.dg/autopar/reduc-8.c: Same.
...

The problem is that when parallelizing reductions in parloops, we change the
order of evaluation, which can mean that we introduce an overflow, where there
was none before. This only yields the same result if the overflow behaviour can
be assumed to wrap. The fix adds this missing check.

However, we can convert the signed reduction to an unsigned one, correctly
parallelize it, and cast the result back to signed.


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

* [Bug tree-optimization/66975] parloops to handle signed int reductions
  2015-07-23 12:35 [Bug tree-optimization/66975] New: parloops to handle signed int reductions vries at gcc dot gnu.org
@ 2015-07-26 17:54 ` vries at gcc dot gnu.org
  2015-07-29 11:42 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2015-07-26 17:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from vries at gcc dot gnu.org ---
This ( https://gcc.gnu.org/ml/gcc-patches/2015-07/msg02064.html ) patches fixes
the problem for operations that do not overflow, f.i. min and max.


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

* [Bug tree-optimization/66975] parloops to handle signed int reductions
  2015-07-23 12:35 [Bug tree-optimization/66975] New: parloops to handle signed int reductions vries at gcc dot gnu.org
  2015-07-26 17:54 ` [Bug tree-optimization/66975] " vries at gcc dot gnu.org
@ 2015-07-29 11:42 ` vries at gcc dot gnu.org
  2015-08-01  8:34 ` vries at gcc dot gnu.org
  2015-08-01  8:36 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2015-07-29 11:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from vries at gcc dot gnu.org ---
(In reply to vries from comment #1)
> This ( https://gcc.gnu.org/ml/gcc-patches/2015-07/msg02064.html ) patches
> fixes the problem for operations that do not overflow, f.i. min and max.

Updated patch: https://gcc.gnu.org/ml/gcc-patches/2015-07/msg02450.html


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

* [Bug tree-optimization/66975] parloops to handle signed int reductions
  2015-07-23 12:35 [Bug tree-optimization/66975] New: parloops to handle signed int reductions vries at gcc dot gnu.org
  2015-07-26 17:54 ` [Bug tree-optimization/66975] " vries at gcc dot gnu.org
  2015-07-29 11:42 ` vries at gcc dot gnu.org
@ 2015-08-01  8:34 ` vries at gcc dot gnu.org
  2015-08-01  8:36 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2015-08-01  8:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from vries at gcc dot gnu.org ---
https://gcc.gnu.org/ml/gcc-cvs/2015-08/msg00003.html :

Author: vries
Date: Sat Aug  1 08:29:29 2015
New Revision: 226463

URL: https://gcc.gnu.org/viewcvs?rev=226463&root=gcc&view=rev
Log:
Allow non-overflow ops in reductions

2015-08-01  Tom de Vries  <tom@codesourcery.com>

        * tree.c (operation_can_overflow, operation_no_trapping_overflow): New
        function.
        * tree.h (operation_can_overflow, operation_no_trapping_overflow):
        Declare.
        * tree-vect-loop.c (vect_is_simple_reduction_1): Use
        operation_no_trapping_overflow.  Allow non-overflow operations.
        * graphite-sese-to-poly.c (is_reduction_operation_p): Allow
non-overflow
        operations.

        * gcc.dg/autopar/reduc-2char.c (init_arrays): Mark with attribute
        optimize ("-ftree-parallelize-loops=0").
        Add successful scans for 2 detected reductions.  Add xfail scans for 3
        detected reductions.
        * gcc.dg/autopar/reduc-2short.c: Same.
        * gcc.dg/autopar/reduc-8.c (init_arrays): Mark with attribute
        optimize ("-ftree-parallelize-loops=0").  Add successful scans for 2
        detected reductions.
        * gcc.dg/vect/trapv-vect-reduc-4.c: Update scan to match vectorized min
        and max reductions.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/graphite-sese-to-poly.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/autopar/reduc-2char.c
    trunk/gcc/testsuite/gcc.dg/autopar/reduc-2short.c
    trunk/gcc/testsuite/gcc.dg/autopar/reduc-8.c
    trunk/gcc/testsuite/gcc.dg/vect/trapv-vect-reduc-4.c
    trunk/gcc/tree-vect-loop.c
    trunk/gcc/tree.c
    trunk/gcc/tree.h


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

* [Bug tree-optimization/66975] parloops to handle signed int reductions
  2015-07-23 12:35 [Bug tree-optimization/66975] New: parloops to handle signed int reductions vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-08-01  8:34 ` vries at gcc dot gnu.org
@ 2015-08-01  8:36 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2015-08-01  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

vries at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-08-01
     Ever confirmed|0                           |1

--- Comment #4 from vries at gcc dot gnu.org ---
https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01817.html :
...
The "proper" solution (see other passes) is to rewrite the reduction
to a wrapping
one (cast to unsigned for the reduction op).
...


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

end of thread, other threads:[~2015-08-01  8:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-23 12:35 [Bug tree-optimization/66975] New: parloops to handle signed int reductions vries at gcc dot gnu.org
2015-07-26 17:54 ` [Bug tree-optimization/66975] " vries at gcc dot gnu.org
2015-07-29 11:42 ` vries at gcc dot gnu.org
2015-08-01  8:34 ` vries at gcc dot gnu.org
2015-08-01  8:36 ` 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).