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]

[tree-ssa] new testcase: dead stores to arrays and structs


2 tests showing that dead stores to array elements and structure
members are not removed by the tree optimizers. The RTL optimizers
remove these dead stores.

It wasn't clear which optimization should have taken care of 
this: dce or dom, so the scan is done on the final .optimized dump.

If approved, please check it in, I don't have commit access.

2003-11-06  Dan Nicolaescu  <dann@ics.uci.edu>

	* gcc.dg/tree-ssa/20031106-1.c: New test.
	* gcc.dg/tree-ssa/20031106-2.c: Likewise.

*** /dev/null	Thu Apr 11 07:25:15 2002
--- gcc/testsuite/gcc.dg/tree-ssa/20031106-1.c	Thu Nov  6 10:32:43 2003
***************
*** 0 ****
--- 1,20 ----
+ /* { dg-do compile } */ 
+ /* { dg-options "-O1 -fdump-tree-optimized" } */
+ 
+ extern void link_error (void);
+ 
+ /* Check for dead stores to an array.  */
+ 
+ void foo (int testarray[])
+ {
+   testarray[0] = 0;
+   testarray[0]++;
+   if (testarray[0] != 1)
+     link_error ();
+ }
+ 
+ /* There should be only one reference to "testarray".  */
+ /* { dg-final { scan-tree-dump-times "testarray" 1 "optimized"} } */
+ 
+ /* There should be no link_error calls.  */
+ /* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"} } */


*** /dev/null	Thu Apr 11 07:25:15 2002
--- gcc/testsuite/gcc.dg/tree-ssa/20031106-2.c	Thu Nov  6 10:32:24 2003
***************
*** 0 ****
--- 1,27 ----
+ /* { dg-do compile } */ 
+ /* { dg-options "-O1 -fdump-tree-optimized" } */
+ 
+ extern void link_error (void);
+ 
+ /* Check for dead stores to a struct.  */
+ 
+ struct s
+ {
+   char d;
+   int a, b;
+   double m;
+ };
+ 
+ void foo (struct s* teststruct)
+ {
+   teststruct->a = 0;
+   teststruct->a++;
+   if (teststruct->a != 1)
+     link_error ();
+ }
+ 
+ /* There should be only one reference to "teststruct".  */
+ /* { dg-final { scan-tree-dump-times "teststruct" 1 "optimized"} } */
+ 
+ /* There should be no link_error calls.  */
+ /* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"} } */


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