[PATCH] Fix PR39636

Richard Guenther rguenther@suse.de
Sat Apr 4 09:27:00 GMT 2009


This fixes PR39636 an oversight in my last forwprop patch.

Bootstrapped on x86_64-unknown-linux-gnu, applied as obvious.

Richard.

2009-04-04  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/39636
	* tree-ssa-forwprop.c
	(forward_propagate_addr_into_variable_array_index): Check for
	GIMPLE_ASSIGN before accessing the rhs code.

	* gcc.c-torture/compile/pr39636.c: New testcase.

Index: gcc/tree-ssa-forwprop.c
===================================================================
*** gcc/tree-ssa-forwprop.c	(revision 145498)
--- gcc/tree-ssa-forwprop.c	(working copy)
*************** forward_propagate_addr_into_variable_arr
*** 668,674 ****
  					       tunit)) != NULL_TREE)
         {
  	 gimple offset_def2 = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (offset_def));
! 	 if (gimple_assign_rhs_code (offset_def2) == MULT_EXPR
  	     && TREE_CODE (gimple_assign_rhs2 (offset_def2)) == INTEGER_CST
  	     && tree_int_cst_equal (gimple_assign_rhs2 (offset_def2), tunit))
  	   {
--- 668,675 ----
  					       tunit)) != NULL_TREE)
         {
  	 gimple offset_def2 = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (offset_def));
! 	 if (is_gimple_assign (offset_def2)
! 	     && gimple_assign_rhs_code (offset_def2) == MULT_EXPR
  	     && TREE_CODE (gimple_assign_rhs2 (offset_def2)) == INTEGER_CST
  	     && tree_int_cst_equal (gimple_assign_rhs2 (offset_def2), tunit))
  	   {
Index: gcc/testsuite/gcc.c-torture/compile/pr39636.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr39636.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr39636.c	(revision 0)
***************
*** 0 ****
--- 1,11 ----
+ typedef float real;
+ typedef real rvec[3];
+ void calc_dx2dx(real *, real *);
+ void phi_sr(int nj,rvec x[],int k)
+ {
+   int i,j;
+   for(i=0; (i<nj-1); i++)
+     for(j=i+1; (j<nj); j++)
+       if (k)
+ 	calc_dx2dx(x[i],x[j]);
+ }



More information about the Gcc-patches mailing list