public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/39331]  New: OpenMP and return-slot-optimization generate invalid gimple
@ 2009-03-01 16:59 rguenth at gcc dot gnu dot org
  2009-03-01 17:27 ` [Bug tree-optimization/39331] " rguenth at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-03-01 16:59 UTC (permalink / raw)
  To: gcc-bugs

from libgomp.c++/pr27337.C at -O3 we get in 042i.inline

  ret.12_15 = &x.8;
  .omp_data_o.11.ret ={v} ret.12_15;
  __builtin_GOMP_parallel_start (_Z3barv.omp_fn.0, &.omp_data_o.11, 4);
  _Z3barv.omp_fn.0 (&.omp_data_o.11);
  __builtin_GOMP_parallel_end ();
  ret.13_16 = .omp_data_o.11.ret;
  &x.8 = ret.13_16;

in main() from inlining foo() here:

<bb 8>:
  x.8 ={v} bar (); [return slot optimization]
  x ={v} x.8;

where bar () looks like

S bar() ()
{
  struct S & ret.5;
  struct .omp_data_s.10 .omp_data_o.11;
  struct S & ret.12;
  struct S & ret.13;

<bb 2>:
  ret.5_1 = <retval>;
  __comp_ctor  (ret.5_1);
  ret.12_2 = <retval>;
  .omp_data_o.11.ret ={v} ret.12_2;
  __builtin_GOMP_parallel_start (_Z3barv.omp_fn.0, &.omp_data_o.11, 4);
  _Z3barv.omp_fn.0 (&.omp_data_o.11);
  __builtin_GOMP_parallel_end ();
  ret.13_3 = .omp_data_o.11.ret;
  <retval> ={v} ret.13_3;
  return <retval>;

}

which is no longer in a form suitable for RSO.

The wrong-gimple is not catched by any verification at the moment (huh...)
but will ICE momentarily during PTA on the alias-improvements branch.

I didn't check if this is in any way a regression.


-- 
           Summary: OpenMP and return-slot-optimization generate invalid
                    gimple
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


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

* [Bug tree-optimization/39331] OpenMP and return-slot-optimization generate invalid gimple
  2009-03-01 16:59 [Bug tree-optimization/39331] New: OpenMP and return-slot-optimization generate invalid gimple rguenth at gcc dot gnu dot org
@ 2009-03-01 17:27 ` rguenth at gcc dot gnu dot org
  2009-03-01 20:49 ` rguenth at gcc dot gnu dot org
  2009-03-01 20:49 ` rguenth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-03-01 17:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2009-03-01 17:26 -------
omp-lower introduces the store to <retval> which seems useless as with
a pass-by-reference retval we will never change the address itself.

    ret.12 = <retval>;
    .omp_data_o.11.ret = ret.12;
    {
      #pragma omp parallel num_threads(4) shared(<retval>) [child fn:
_Z3barv.omp_fn.0 (.omp_data_o.11)]
...
    }
    ret.13 = .omp_data_o.11.ret;
    <retval> = ret.13;


The following seems to fix it:

Index: omp-low.c
===================================================================
--- omp-low.c   (revision 144492)
+++ omp-low.c   (working copy)
@@ -2823,7 +2823,14 @@ lower_send_shared_vars (gimple_seq *ilis
          x = build_sender_ref (ovar, ctx);
          gimplify_assign (x, var, ilist);

-         if (!TREE_READONLY (var))
+         if (!TREE_READONLY (var)
+             /* We don't need to receive a new reference to a result
+                or parm decl.  In fact we may not store to it as we will
+                invalidate any pending RSO and generate wrong gimple
+                during inlining.  */
+             && !((TREE_CODE (var) == RESULT_DECL
+                   || TREE_CODE (var) == PARM_DECL)
+                  && DECL_BY_REFERENCE (var)))
            {
              x = build_sender_ref (ovar, ctx);
              gimplify_assign (var, x, olist);


-- 


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


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

* [Bug tree-optimization/39331] OpenMP and return-slot-optimization generate invalid gimple
  2009-03-01 16:59 [Bug tree-optimization/39331] New: OpenMP and return-slot-optimization generate invalid gimple rguenth at gcc dot gnu dot org
  2009-03-01 17:27 ` [Bug tree-optimization/39331] " rguenth at gcc dot gnu dot org
@ 2009-03-01 20:49 ` rguenth at gcc dot gnu dot org
  2009-03-01 20:49 ` rguenth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-03-01 20:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2009-03-01 20:49 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.4.0


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


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

* [Bug tree-optimization/39331] OpenMP and return-slot-optimization generate invalid gimple
  2009-03-01 16:59 [Bug tree-optimization/39331] New: OpenMP and return-slot-optimization generate invalid gimple rguenth at gcc dot gnu dot org
  2009-03-01 17:27 ` [Bug tree-optimization/39331] " rguenth at gcc dot gnu dot org
  2009-03-01 20:49 ` rguenth at gcc dot gnu dot org
@ 2009-03-01 20:49 ` rguenth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-03-01 20:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2009-03-01 20:49 -------
Subject: Bug 39331

Author: rguenth
Date: Sun Mar  1 20:49:14 2009
New Revision: 144531

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144531
Log:
2009-03-01  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/39331
        * omp-low.c (lower_send_shared_vars): Do not receive new
        values for the reference of DECL_BY_REFERENCE parms or results.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/omp-low.c


-- 


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


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

end of thread, other threads:[~2009-03-01 20:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-01 16:59 [Bug tree-optimization/39331] New: OpenMP and return-slot-optimization generate invalid gimple rguenth at gcc dot gnu dot org
2009-03-01 17:27 ` [Bug tree-optimization/39331] " rguenth at gcc dot gnu dot org
2009-03-01 20:49 ` rguenth at gcc dot gnu dot org
2009-03-01 20:49 ` rguenth at gcc dot gnu dot 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).