Hi,

given that we already have a workaround for zero size increase
estimates from estimate_ipcp_clone_size_and_time, I see little reason
not to extend it to negative values too, 0 is really just as bad as -2
that we are getting in the testcase.  Hopefully this will allow peple
who hit this bug proceed with their testing.

Bootstrapped and tested on x86-64-linux with no regressions.
OK for trunk?

Thanks,

Martin


2011-12-20  Martin Jambor  <mjam...@suse.cz>

        PR tree-optimization/51600
        * ipa-cp.c (estimate_local_effects): Turn also negative size
        estimates to plus one.

        * gcc/testsuite/g++.dg/ipa/pr51600.C: New test.

Index: src/gcc/ipa-cp.c
===================================================================
--- src.orig/gcc/ipa-cp.c
+++ src/gcc/ipa-cp.c
@@ -1409,12 +1409,11 @@ estimate_local_effects (struct cgraph_no
            + devirtualization_time_bonus (node, known_csts, known_binfos)
            + removable_params_cost + emc;
 
-         gcc_checking_assert (size >=0);
          /* The inliner-heuristics based estimates may think that in certain
-            contexts some functions do not have any size at all but we want
-            all specializations to have at least a tiny cost, not least not to
-            divide by zero.  */
-         if (size == 0)
+            contexts some functions do not have any size at all or that given
+            the constants it can even shrink, but we want all specializations
+            to have at least a tiny positive cost.  */
+         if (size <= 0)
            size = 1;
 
          if (dump_file && (dump_flags & TDF_DETAILS))
Index: src/gcc/testsuite/g++.dg/ipa/pr51600.C
===================================================================
--- /dev/null
+++ src/gcc/testsuite/g++.dg/ipa/pr51600.C
@@ -0,0 +1,19 @@
+// { dg-do compile }
+// { dg-options "-O3" }
+
+template<class T> inline T min(T a, T b) { return a < b ? a : b; }
+double cornerbound(double *P, double (*m)(double, double))
+{
+  double b=m(P[0],P[3]);
+  return m(b,P[12]);
+}
+void bound(double *P, double (*m)(double, double), double b)
+{
+  m(b,cornerbound(P,m));
+}
+void bounds(double fuzz, unsigned maxdepth)
+{
+  double Px[]={};
+  double bx=Px[0];
+  bound(Px,min,bx);
+}

Reply via email to