[PATCH] fold_stmt returns non-gimple

Richard Guenther rguenth@tat.physik.uni-tuebingen.de
Wed Apr 27 15:09:00 GMT 2005


fold_stmt (and its helper set_rhs) happily accept non-gimple
from fold of the form

 x = ADDR_EXPR (ARRAY_REF (a, NOP_EXPR(unsigned int, i)));

arguably set_rhs is at fault here, and it doesn't even try
to verify gimpliness of the ADDR_EXPR operand.

Fixed f.i. by the following simple patch.  Compiled and
tested for C on i686-pc-linux-gnu with some other applied
patches that cause the failure.  Ok for mainline?

Richard.


2005-04-27  Richard Guenther  <rguenth@gcc.gnu.org>

	* tree-ssa-propagate.c (set_rhs): Check operand of
	ADDR_EXPR for gimpliness, too.


Index: tree-ssa-propagate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-propagate.c,v
retrieving revision 2.15
diff -c -3 -p -r2.15 tree-ssa-propagate.c
*** tree-ssa-propagate.c	24 Apr 2005 14:15:13 -0000	2.15
--- tree-ssa-propagate.c	27 Apr 2005 13:23:29 -0000
*************** set_rhs (tree *stmt_p, tree expr)
*** 571,577 ****
  	  || !is_gimple_val (TREE_OPERAND (expr, 1)))
  	return false;
      }
!   else if (TREE_CODE_CLASS (code) == tcc_unary)
      {
        if (!is_gimple_val (TREE_OPERAND (expr, 0)))
  	return false;
--- 571,578 ----
  	  || !is_gimple_val (TREE_OPERAND (expr, 1)))
  	return false;
      }
!   else if (TREE_CODE_CLASS (code) == tcc_unary
! 	   || code == ADDR_EXPR)
      {
        if (!is_gimple_val (TREE_OPERAND (expr, 0)))
  	return false;



More information about the Gcc-patches mailing list