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 PR46216


Bootstrapped and teste don x86_64-unknwon-linxug-nu, applied.

RIchard.

2010-11-02  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/46216
	* tree-ssa-forwprop.c (tree_ssa_forward_propagate_single_use_vars):
	Check if we can propagate from a POINTER_PLUS_EXPR before doing so.

	* gcc.dg/torture/pr46216.c: New testcase.

Index: gcc/tree-ssa-forwprop.c
===================================================================
*** gcc/tree-ssa-forwprop.c	(revision 166172)
--- gcc/tree-ssa-forwprop.c	(working copy)
*************** tree_ssa_forward_propagate_single_use_va
*** 1983,1989 ****
  		  else
  		    gsi_next (&gsi);
  		}
! 	      else if (gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR)
  		{
  		  if (TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST
  		      /* ???  Better adjust the interface to that function
--- 1983,1990 ----
  		  else
  		    gsi_next (&gsi);
  		}
! 	      else if (gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR
! 		       && can_propagate_from (stmt))
  		{
  		  if (TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST
  		      /* ???  Better adjust the interface to that function
Index: gcc/testsuite/gcc.dg/torture/pr46216.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr46216.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr46216.c	(revision 0)
***************
*** 0 ****
--- 1,24 ----
+ /* { dg-do compile } */
+ 
+ typedef int Embryo_Cell;
+ int
+ embryo_program_run(Embryo_Cell *cip)
+ {
+     unsigned char op;
+     Embryo_Cell offs;
+     static const void *switchtable[256] = {
+ 	&&SWITCHTABLE_EMBRYO_OP_NONE, &&SWITCHTABLE_EMBRYO_OP_LOAD_PRI
+     };
+     for (;;)
+       {
+ 	op = *cip++;
+ 	while (1) {
+ 	    goto *switchtable[op];
+ SWITCHTABLE_EMBRYO_OP_LOAD_PRI:
+ 	    offs = *(Embryo_Cell *)cip++;
+ SWITCHTABLE_EMBRYO_OP_NONE:
+ 	    break;
+ 	};
+       }
+     return offs;
+ }


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