]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/58209 (ICE in extract_range_from_binary_expr, at...
authorJakub Jelinek <jakub@redhat.com>
Wed, 7 May 2014 16:00:33 +0000 (18:00 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 7 May 2014 16:00:33 +0000 (18:00 +0200)
Backported from mainline
2013-08-23  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/58209
* tree-tailcall.c (find_tail_calls): Give up for pointer result types
if m or a is non-NULL.

* gcc.c-torture/execute/pr58209.c: New test.

From-SVN: r210170

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr58209.c [new file with mode: 0644]
gcc/tree-tailcall.c

index f2b7b9e42dada33d26bd6eb738552b130078224e..8838f62abd35d212f17129d95a75999438955cab 100644 (file)
@@ -1,6 +1,12 @@
 2014-05-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2013-08-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/58209
+       * tree-tailcall.c (find_tail_calls): Give up for pointer result types
+       if m or a is non-NULL.
+
        2013-07-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/57777
index 385241cb6f764d74857dd3c1bd40377142bd9ee3..e5bd7ce49ae295bb9a5e0436910b1418b397ac8c 100644 (file)
@@ -1,6 +1,11 @@
 2014-05-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2013-08-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/58209
+       * gcc.c-torture/execute/pr58209.c: New test.
+
        2013-07-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/57777
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr58209.c b/gcc/testsuite/gcc.c-torture/execute/pr58209.c
new file mode 100644 (file)
index 0000000..78743bf
--- /dev/null
@@ -0,0 +1,32 @@
+/* PR tree-optimization/58209 */
+
+extern void abort (void);
+typedef __INTPTR_TYPE__ T;
+T buf[1024];
+
+T *
+foo (T n)
+{
+  if (n == 0)
+    return (T *) buf;
+  T s = (T) foo (n - 1);
+  return (T *) (s + sizeof (T));
+}
+
+T *
+bar (T n)
+{
+  if (n == 0)
+    return buf;
+  return foo (n - 1) + 1;
+}
+
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 27; i++)
+    if (foo (i) != buf + i || bar (i) != buf + i)
+      abort ();
+  return 0;
+}
index f07297e86c9c9d810d6091ff28a6059132f60963..e5387008b8be94a6911ba0febcde5c90f83cd44c 100644 (file)
@@ -576,6 +576,11 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
   if (!tail_recursion && (m || a))
     return;
 
+  /* For pointers don't allow additions or multiplications.  */
+  if ((m || a)
+      && POINTER_TYPE_P (TREE_TYPE (DECL_RESULT (current_function_decl))))
+    return;
+
   nw = XNEW (struct tailcall);
 
   nw->call_gsi = gsi;