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 PR44977


This fixes DOM creating invalid SSA form by propagating g_67.1_6
into its definition statement.

<bb 9>:
  # prephitmp.12_36 = PHI <g_67.1_6(9)>
  g_67.1_6 = prephitmp.12_36;
  goto <bb 9>;

As this can only happen from dead (unreachable) code we can just
avoid doing it as cfgcleanup will remove the code anyway.

Bootstrapped and tested on x86_64-unknown-linux-gnu, committed.

2010-07-20  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/44977
	* tree-ssa-dom.c (propagate_rhs_into_lhs): Do not create invalid
	SSA form.

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

Index: gcc/tree-ssa-dom.c
===================================================================
*** gcc/tree-ssa-dom.c	(revision 162328)
--- gcc/tree-ssa-dom.c	(working copy)
*************** propagate_rhs_into_lhs (gimple stmt, tre
*** 2559,2564 ****
--- 2559,2578 ----
  	      continue;
  	    }
  
+ 	  /* It's not ok to propagate into the definition stmt of RHS.
+ 		<bb 9>:
+ 		  # prephitmp.12_36 = PHI <g_67.1_6(9)>
+ 		  g_67.1_6 = prephitmp.12_36;
+ 		  goto <bb 9>;
+ 	     While this is strictly all dead code we do not want to
+ 	     deal with this here.  */
+ 	  if (TREE_CODE (rhs) == SSA_NAME
+ 	      && SSA_NAME_DEF_STMT (rhs) == use_stmt)
+ 	    {
+ 	      all = false;
+ 	      continue;
+ 	    }
+ 
  	  /* Dump details.  */
  	  if (dump_file && (dump_flags & TDF_DETAILS))
  	    {
Index: gcc/testsuite/gcc.dg/torture/pr44977.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr44977.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr44977.c	(revision 0)
***************
*** 0 ****
--- 1,41 ----
+ /* { dg-do compile } */
+ /* { dg-options "-w" } */
+ 
+ static unsigned short
+ foo (unsigned short ui1, unsigned short ui2)
+ {
+   return ui1 - ui2;
+ }
+ 
+ static unsigned short
+ bar (unsigned ui1, unsigned short ui2)
+ {
+   return ui1 + ui2;
+ }
+ 
+ struct S1
+ {
+   const short f3;
+ };
+ int g_31;
+ short g_67;
+ struct S1 g_68[2][5][9][1][1] = {
+ };
+ 
+ int func_90 (int);
+ 
+ int int329 (int * const *const int32p_81, short ** p_82)
+ {
+   short l_169[8];
+   for (g_31 = 0; g_31 <= 0; g_31 = foo (g_31, 1))
+     {
+       short l_85;
+ lbl_89:g_67 ^= l_85;
+        for (l_85 = 0; l_85 >= 0; l_85 = bar)
+ 	 if (g_31)
+ 	   goto lbl_89;
+        func_90 (1), g_68[0][2][2][0][0].f3, 0;
+     }
+   return l_169[6];
+ }
+ 


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