[PATCH]: PR 30590 invalid optimization by tree-nrv

Seongbae Park seongbae.park@gmail.com
Wed Mar 14 04:57:00 GMT 2007


Hi,

This is for PR 30590 where named return value optimization
wasn't checking for the partial update of the return result,
doing the transformation when it shouldn't.
The fix has been bootstrapped and regtested on i686 with no extra regressions.
After it has been checked in the mainline, I plan to backport this
to appropriate branch.
OK ?

2007-03-13  Seongbae Park <seongbae.park@gmail.com>

        PR tree-optimization/30590

        * tree-nrv.c (tree_nrv): Check for the partial update of the
return value.

-- 
#pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com"
-------------- next part --------------
Index: gcc/tree-nrv.c
===================================================================
--- gcc/tree-nrv.c	(revision 122871)
+++ gcc/tree-nrv.c	(working copy)
@@ -163,6 +163,14 @@ tree_nrv (void)
 						     result_type))
 		return 0;
 	    }
+	  else if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT)
+	    {
+	      tree addr = get_base_address (GIMPLE_STMT_OPERAND (stmt, 0));
+	       /* If there's any MODIFY of component of RESULT, 
+		  then bail out.  */
+	      if (addr && addr == result)
+		return 0;
+	    }
 	}
     }
 


More information about the Gcc-patches mailing list