--- /dev/null
+/* PR/113080 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+int a,b,n;
+int w;
+void fun1(int t)
+{
+ for(int i=0;i<100;i++)
+ {
+ a+=w;
+ b-=w;
+ t+=a+b;
+ }
+ n=t;
+}
+
+/* We should apply final value replacement to all reductions and
+ elide the loop. */
+/* { dg-final { scan-tree-dump-times "<bb" 1 "optimized" } } */
uint64_t expanded_size = 0;
*cond_overflow_p = false;
return (expression_expensive_p (expr, cond_overflow_p, cache, expanded_size)
- || expanded_size > cache.elements ());
+ /* ??? Both the explicit unsharing and gimplification of expr will
+ expand shared trees to multiple copies.
+ Guard against exponential growth by counting the visits and
+ comparing againt the number of original nodes. Allow a tiny
+ bit of duplication to catch some additional optimizations. */
+ || expanded_size > (cache.elements () + 1));
}
/* Match.pd function to match bitwise inductive expression.
fprintf (dump_file, "\n");
}
any = true;
+ /* ??? Here we'd like to have a unshare_expr that would assign
+ shared sub-trees to new temporary variables either gimplified
+ to a GIMPLE sequence or to a statement list (keeping this a
+ GENERIC interface). */
def = unshare_expr (def);
remove_phi_node (&psi, false);