+2007-07-02 Jakub Jelinek <jakub@redhat.com>
+
+ * tree-nrv.c (dest_safe_for_nrv_p): Grok any handled_component_p,
+ SSA_NAMEs, RESULT_DECLs and PARM_DECLs.
+
2007-07-02 Richard Guenther <rguenther@suse.de>
* tree-ssa.c (useless_type_conversion_p): Document
+2007-07-02 Jakub Jelinek <jakub@redhat.com>
+
+ * g++.dg/opt/nrv12.C: New test.
+ * gcc.target/i386/nrv1.c: New test.
+
2007-07-02 Ira Rosen <irar@il.ibm.com>
PR tree-optimization/32230
--- /dev/null
+/* Verify that gimple-level NRV is occurring even for RESULT_DECLs. *./
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+/* { dg-require-effective-target ilp32 } */
+
+struct P
+{
+ long long l;
+ int a;
+ unsigned int b;
+ P(long long x) : l(x) {}
+};
+
+P foo (P);
+P bar (P);
+
+P foo (P x)
+{
+ P y = P (-1LL);
+ y = bar (x);
+ return y;
+}
+
+/* { dg-final { scan-tree-dump-times "return slot optimization" 1 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
--- /dev/null
+/* Verify that gimple-level NRV is occurring even for SSA_NAMEs. *./
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+/* { dg-require-effective-target ilp32 } */
+
+_Complex double foo (_Complex double x)
+{
+ return __builtin_cexp (x);
+}
+
+/* { dg-final { scan-tree-dump-times "return slot optimization" 1 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
static bool
dest_safe_for_nrv_p (tree dest)
{
- switch (TREE_CODE (dest))
- {
- case VAR_DECL:
- {
- subvar_t subvar;
- if (is_call_clobbered (dest))
- return false;
- for (subvar = get_subvars_for_var (dest);
- subvar;
- subvar = subvar->next)
- if (is_call_clobbered (subvar->var))
- return false;
- return true;
- }
- case ARRAY_REF:
- case COMPONENT_REF:
- return dest_safe_for_nrv_p (TREE_OPERAND (dest, 0));
- default:
- return false;
- }
+ subvar_t subvar;
+
+ while (handled_component_p (dest))
+ dest = TREE_OPERAND (dest, 0);
+
+ if (! SSA_VAR_P (dest))
+ return false;
+
+ if (TREE_CODE (dest) == SSA_NAME)
+ dest = SSA_NAME_VAR (dest);
+
+ if (is_call_clobbered (dest))
+ return false;
+ for (subvar = get_subvars_for_var (dest); subvar; subvar = subvar->next)
+ if (is_call_clobbered (subvar->var))
+ return false;
+ return true;
}
/* Walk through the function looking for GIMPLE_MODIFY_STMTs with calls that