re PR tree-optimization/50613 (ICE: tree check: expected ssa_name, have addr_expr in find_equal_ptrs, at tree-ssa-strlen.c:712 with -foptimize-strlen -fno-tree-ccp)

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
This commit is contained in:
Jakub Jelinek 2011-10-05 20:09:56 +02:00 committed by Jakub Jelinek
parent 9974107a90
commit 97246d787a
4 changed files with 40 additions and 4 deletions

View 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

View 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.

View File

@ -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);
}

View 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;
}