------- Comment #7 from spark at gcc dot gnu dot org  2007-03-13 16:15 -------
tree-nrv code doesn't see:
<bb 2>:
  <retval>.type = 0;

because it only looks at GIMPLE_MODIFY with the operand 0 as the return value.
In this case, there's GIMPLE_MODIFY of the component of the return value
hence not all modification to the return value.
The following patch seems to get around the problem:

Index: tree-nrv.c
===================================================================
--- tree-nrv.c  (revision 122871)
+++ tree-nrv.c  (working copy)
@@ -163,6 +163,12 @@ tree_nrv (void)
                                                     result_type))
                return 0;
            }
+         else if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT
+                  && TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 0)) ==
COMPONENT_REF
+                  && TREE_OPERAND (GIMPLE_STMT_OPERAND (stmt, 0), 0) ==
result)
+           /* If there's any MODIFY of component of RESULT,
+              then bail out.  */
+           return 0;
        }
     }


I'm not sure this is sufficient - can there be any other 
gimple statement combination that modifies only part of RESULT ?


-- 

spark at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |spark at gcc dot gnu dot org


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

Reply via email to