This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix ICE in find_equal_ptrs (PR tree-optimization/50613)


Hi!

I didn't consider that the rhs1 of a gimple cast might be something
other than SSA_NAME.  Fixed thusly, bootstrapped/regtested on x86_64-linux
and i686-linux, ok for trunk?

2011-10-05  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/50613
	* tree-ssa-strlen.c (find_equal_ptrs): If CASE_CONVERT
	operand is ADDR_EXPR, fallthru into ADDR_EXPR handling,
	and if it is neither that not SSA_NAME, give up.

	* gcc.dg/pr50613.c: New test.

--- gcc/tree-ssa-strlen.c.jj	2011-10-05 08:13:55.000000000 +0200
+++ gcc/tree-ssa-strlen.c	2011-10-05 08:19:16.000000000 +0200
@@ -692,6 +692,14 @@ find_equal_ptrs (tree ptr, int idx)
 	{
 	case SSA_NAME:
 	  break;
+	CASE_CONVERT:
+	  if (!POINTER_TYPE_P (TREE_TYPE (ptr)))
+	    return;
+	  if (TREE_CODE (ptr) == SSA_NAME)
+	    break;
+	  if (TREE_CODE (ptr) != ADDR_EXPR)
+	    return;
+	  /* FALLTHRU */
 	case ADDR_EXPR:
 	  {
 	    int *pidx = addr_stridxptr (TREE_OPERAND (ptr, 0));
@@ -699,10 +707,6 @@ find_equal_ptrs (tree ptr, int idx)
 	      *pidx = idx;
 	    return;
 	  }
-	CASE_CONVERT:
-	  if (POINTER_TYPE_P (TREE_TYPE (ptr)))
-	    break;
-	  return;
 	default:
 	  return;
 	}
--- gcc/testsuite/gcc.dg/pr50613.c.jj	2011-10-05 08:22:32.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr50613.c	2011-10-05 08:21:31.000000000 +0200
@@ -0,0 +1,20 @@
+/* PR tree-optimization/50613 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-ccp" } */
+
+#include "strlenopt.h"
+
+char buf[26];
+
+static inline void
+bar (char *__restrict dest, const char *__restrict src)
+{
+  strcpy (dest, src);
+}
+
+void
+foo (char *p)
+{
+  if (strlen (p) < 50)
+    bar (buf, p);
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]