re PR tree-optimization/50613 (ICE: tree check: expected ssa_name, have addr_expr...
authorJakub Jelinek <jakub@redhat.com>
Wed, 5 Oct 2011 18:09:56 +0000 (20:09 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 5 Oct 2011 18:09:56 +0000 (20:09 +0200)
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.

From-SVN: r179567

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr50613.c [new file with mode: 0644]
gcc/tree-ssa-strlen.c

index 800d69aab78e3911b73fbffe8ec69296f8515839..b37b082fa4b276d2ab05d0053849e48bede7718b 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2011-10-05  Richard Henderson  <rth@redhat.com>
 
        * tree-vect-generic.c (vector_element): Never fail.  Use
index 4ad91390b2ace614014fdd97a0b96199624497b7..df73460915457fbc8b5f3f8770718995cd7dba92 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/50613
+       * gcc.dg/pr50613.c: New test.
+
 2011-10-05  Richard Henderson  <rth@redhat.com>
 
        * gcc.c-torture/execute/vect-shuffle-1.c: Rewrite.
diff --git a/gcc/testsuite/gcc.dg/pr50613.c b/gcc/testsuite/gcc.dg/pr50613.c
new file mode 100644 (file)
index 0000000..27c6fba
--- /dev/null
@@ -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);
+}
index b2ee2f96f44b34c18a7e4b68228a10f48e6da808..d997c73451e707c150467f5c0079d768f0afe94a 100644 (file)
@@ -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;
        }