diff mbox series

Do not ICE on roundoff errors in ipa-inline

Message ID 20180114112127.GA79167@kam.mff.cuni.cz
State New
Headers show
Series Do not ICE on roundoff errors in ipa-inline | expand

Commit Message

Jan Hubicka Jan. 14, 2018, 11:21 a.m. UTC
Hi,
this patch fixes ICE on the testcase where we estimate function body
to be rather slow and get roundoff error out of sreal.

Honza

	PR ipa/83051
	* gcc.c-torture/compile/pr83051.c: New testcase.
	* ipa-inline.c (edge_badness): Tolerate roundoff errors.
diff mbox series

Patch

Index: testsuite/gcc.c-torture/compile/pr83051.c
===================================================================
--- testsuite/gcc.c-torture/compile/pr83051.c	(revision 0)
+++ testsuite/gcc.c-torture/compile/pr83051.c	(working copy)
@@ -0,0 +1,31 @@ 
+
+int a[1], b, c, d, e, f, g, h;
+
+void fn1 (int p)
+{ 
+  b = b >> 8 ^ a[b ^ (c & 5)] >> 8 ^ a[(b ^ c) & 5];
+  b = b >> 8 ^ a[(b ^ c) & 5];
+}
+
+static void fn2 ()
+{ 
+  int k;
+  while (1)
+    while (e)
+      { 
+        while (g)
+          while (h)
+            for (k = 0; k < 6; k++)
+              while (f)
+                fn1 (0);
+        fn1 (0);
+        fn1 (0);
+        fn1 (0);
+      }
+}
+
+int main ()
+{ 
+  fn2 ();
+  return 0;
+}
Index: ipa-inline.c
===================================================================
--- ipa-inline.c	(revision 256647)
+++ ipa-inline.c	(working copy)
@@ -993,7 +993,8 @@  edge_badness (struct cgraph_edge *edge,
   /* Check that inlined time is better, but tolerate some roundoff issues.
      FIXME: When callee profile drops to 0 we account calls more.  This
      should be fixed by never doing that.  */
-  gcc_checking_assert ((edge_time - callee_info->time).to_int () <= 0
+  gcc_checking_assert ((edge_time * 100
+			- callee_info->time * 101).to_int () <= 0
 			|| callee->count.ipa ().initialized_p ());
   gcc_checking_assert (growth <= callee_info->size);