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 testcases


This is a small handful of new test cases for the tree-ssa dominator
optimizers.  Many fail right now, but they represent tests for the
various improvements in my queue for the dominator optimizers.

They're primarily testing that the dominator optimizer is removing
redundant statements.  Though there are a couple tests to verify
that the dominator optimizer did not get overly aggressive.

Again, many of these are going to fail in various ways until I flush
out my queue of improvements.


        * gcc.dg/tree-ssa/20030703-1.c: New test.
        * gcc.dg/tree-ssa/20030703-2.c: New test.
        * gcc.dg/tree-ssa/20030708-1.c: New test.
        * gcc.dg/tree-ssa/20030709-1.c: New test.
        * gcc.dg/tree-ssa/20030709-2.c: New test.
        * gcc.dg/tree-ssa/20030709-3.c: New test.
        * gcc.dg/tree-ssa/20030710-1.c: New test.
        * gcc.dg/tree-ssa/20030711-1.c: New test.
        * gcc.dg/tree-ssa/20030711-2.c: New test.
        * gcc.dg/tree-ssa/20030711-3.c: New test.
        * gcc.dg/tree-ssa/20030714-1.c: New test.

Index: gcc.dg/tree-ssa/20030703-1.c
===================================================================
RCS file: gcc.dg/tree-ssa/20030703-1.c
diff -N gcc.dg/tree-ssa/20030703-1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/tree-ssa/20030703-1.c	15 Jul 2003 19:23:24 -0000
***************
*** 0 ****
--- 1,21 ----
+ /* { dg-do compile */
+ /* { dg-options "-O1 -fdump-tree-ssa" } */
+   
+ 
+ extern int blah[];
+ 
+ foo(int index)
+ {
+   if (blah [(unsigned int)index] != 0)
+     abort ();
+   if (blah [(unsigned int)index] != 0)
+     abort ();
+ }
+ 
+ /* There should be precisely one load of blah.  If there is
+    more than one, then the dominator optimizations failed.  */
+ /* { dg-final { scan-tree-dump-times "blah" 1 "ssa"} } */
+  
+ /* There should be exactly one IF conditional.  */
+ /* { dg-final { scan-tree-dump-times "if " 1 "ssa"} } */
+ 
Index: gcc.dg/tree-ssa/20030703-2.c
===================================================================
RCS file: gcc.dg/tree-ssa/20030703-2.c
diff -N gcc.dg/tree-ssa/20030703-2.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/tree-ssa/20030703-2.c	15 Jul 2003 19:23:24 -0000
***************
*** 0 ****
--- 1,38 ----
+ /* { dg-do compile */
+ /* { dg-options "-O1 -fdump-tree-ssa" } */
+                                                                              

+ union tree_node;
+ typedef union tree_node *tree;
+ extern const char tree_code_type[];
+ 
+ union tree_node
+ {
+   int code;
+   long pointer_alias_set;
+ };
+ 
+ long
+ get_alias_set (t)
+      tree t;
+ {
+   if (tree_code_type[t->code])
+     abort ();
+   if (t->pointer_alias_set)
+     {
+       tree __t = t;
+       if (tree_code_type[__t->code])
+ 	abort ();
+     }
+ }
+ 
+ /* There should be precisely one load of {t,__t}->code.  If there is
+    more than one, then the dominator optimizations failed.  */
+ /* { dg-final { scan-tree-dump-times "->code" 1 "ssa"} } */
+                                                                              

+ /* There should be precisely one load of tree_code_type.  If there is
+    more than one, then the dominator optimizations failed.  */
+ /* { dg-final { scan-tree-dump-times "tree_code_type" 1 "ssa"} } */
+ 
+ /* There should be two IF conditionals.  */
+ /* { dg-final { scan-tree-dump-times "if " 2 "ssa"} } */
+ 
Index: gcc.dg/tree-ssa/20030708-1.c
===================================================================
RCS file: gcc.dg/tree-ssa/20030708-1.c
diff -N gcc.dg/tree-ssa/20030708-1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/tree-ssa/20030708-1.c	15 Jul 2003 19:23:24 -0000
***************
*** 0 ****
--- 1,41 ----
+ /* { dg-do compile */
+ /* { dg-options "-O1 -fdump-tree-ssa" } */
+ struct rtx_def;
+ typedef struct rtx_def *rtx;
+ enum rtx_code
+ {
+   CALL_INSN,
+   EXPR_LIST,
+   NOTE
+ };
+ 
+ struct rtx_def
+ {
+ 
+   enum rtx_code code:16;
+ };
+ 
+ static int
+ nonlocal_mentioned_p (x)
+      rtx x;
+ {
+   if (x->code == CALL_INSN)
+     {
+       rtx const _rtx = ((x));
+       if (_rtx->code != CALL_INSN
+ 	  && _rtx->code != NOTE
+ 	  && _rtx->code != EXPR_LIST)
+ 	abort ();
+     }
+ 
+   blah (&x);
+ }
+ 
+ /* There should be precisely one cast to a short unsigned int.  If there is
+    more than one, then the dominator optimizations failed.  */
+ /* { dg-final { scan-tree-dump-times "\\(short unsigned int\\)" 1 "ssa"} } */
+                                                                              

+ /* There should be two IF conditionals.  */
+ /* { dg-final { scan-tree-dump-times "if " 2 "ssa"} } */
+                                                                              

+ 
Index: gcc.dg/tree-ssa/20030709-1.c
===================================================================
RCS file: gcc.dg/tree-ssa/20030709-1.c
diff -N gcc.dg/tree-ssa/20030709-1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/tree-ssa/20030709-1.c	15 Jul 2003 19:23:24 -0000
***************
*** 0 ****
--- 1,15 ----
+ /* { dg-do compile */
+ /* { dg-options "-O1 -fdump-tree-ssa" } */
+                                                                              

+ static int copying_arguments;
+ static int
+ foo ()
+ {
+   unsigned int regno;
+   if (regno < 53 && copying_arguments)
+     if (regno >= 53)
+ 	return 1;
+ }
+ 
+ /* There should be no IF conditionals.  */
+ /* { dg-final { scan-tree-dump-times "if " 0 "ssa"} } */
Index: gcc.dg/tree-ssa/20030709-2.c
===================================================================
RCS file: gcc.dg/tree-ssa/20030709-2.c
diff -N gcc.dg/tree-ssa/20030709-2.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/tree-ssa/20030709-2.c	15 Jul 2003 19:23:24 -0000
***************
*** 0 ****
--- 1,47 ----
+ /* { dg-do compile */
+ /* { dg-options "-O1 -fdump-tree-ssa" } */
+   
+ struct rtx_def;
+ typedef struct rtx_def *rtx;
+ union tree_node;
+ typedef union tree_node *tree;
+ typedef struct mem_attrs
+ {
+   int  foo;
+ 
+ } mem_attrs;
+ union rtunion_def
+ {
+   mem_attrs *rtmem;
+ };
+ typedef union rtunion_def rtunion;
+ struct rtx_def
+ {
+   rtunion fld[1];
+ };
+ struct tree_decl
+ {
+   rtx rtl;
+ };
+ union tree_node
+ {
+   struct tree_decl decl;
+ };
+ void *
+ get_alias_set (t)
+      tree t;
+ {
+   long set;
+   if (t->decl.rtl)
+     return (t->decl.rtl->fld[1].rtmem 
+ 	    ? 0
+ 	    : (((t->decl.rtl ? t->decl.rtl : (make_decl_rtl (t, 0), t->decl.rtl)))->
fld[1]).rtmem);
+ }
+ 
+ /* There should be precisely one load of ->decl.rtl.  If there is
+    more than, then the dominator optimizations failed.  */
+ /* { dg-final { scan-tree-dump-times "->decl\\.rtl" 1 "ssa"} } */
+   
+ /* There should be two IF statements.
+ /* { dg-final { scan-tree-dump-times "if " 2 "ssa"} } */
+ 
Index: gcc.dg/tree-ssa/20030709-3.c
===================================================================
RCS file: gcc.dg/tree-ssa/20030709-3.c
diff -N gcc.dg/tree-ssa/20030709-3.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/tree-ssa/20030709-3.c	15 Jul 2003 19:23:24 -0000
***************
*** 0 ****
--- 1,45 ----
+ /* { dg-do compile */
+ /* { dg-options "-O1 -fdump-tree-ssa" } */
+   
+ 
+ union tree_node;
+ typedef union tree_node *tree;
+ enum tree_code
+ {
+   TREE_VEC = 20,
+ };
+ struct tree_common
+ {
+   int code;
+ };
+ struct tree_type
+ {
+   tree binfo;
+ };
+ union tree_node
+ {
+   struct tree_common common;
+   struct tree_type type;
+ };
+ void
+ record_component_aliases (type)
+      tree type;
+ {
+   const tree __z = type->type.binfo;
+   if (type->type.binfo->common.code != TREE_VEC)
+     abort ();
+ 
+   if (__z->common.code != TREE_VEC)
+     abort ();
+ }
+ 
+ /* There should be precisely one load of type.binfo.  If there is
+    more than one, then the dominator optimizations failed.  */
+ /* { dg-final { scan-tree-dump-times "type\\.binfo" 1 "ssa"} } */
+  
+ /* There should be precisely one load of common.code.  If there is
+    more than one, then the dominator optimizations failed.  */
+ /* { dg-final { scan-tree-dump-times "common\\.code" 1 "ssa"} } */
+  
+ /* There should be one IF conditional.  */
+ /* { dg-final { scan-tree-dump-times "if " 1 "ssa"} } */
Index: gcc.dg/tree-ssa/20030710-1.c
===================================================================
RCS file: gcc.dg/tree-ssa/20030710-1.c
diff -N gcc.dg/tree-ssa/20030710-1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/tree-ssa/20030710-1.c	15 Jul 2003 19:23:24 -0000
***************
*** 0 ****
--- 1,53 ----
+ /* { dg-do compile */
+ /* { dg-options "-O1 -fdump-tree-ssa" } */
+ 
+ union tree_node;
+ typedef union tree_node *tree;
+ struct tree_vec
+ {
+   int length;
+   tree a[1];
+ };
+ struct tree_type
+ {
+   tree binfo;
+ };
+ union tree_node
+ {
+   struct tree_type type;
+   struct tree_vec vec;
+ };
+ void
+ record_component_aliases (type)
+      tree type;
+ {
+   if (type->type.binfo->vec.length)
+     abort ();
+   for (; ((
+ 	    {
+ 	    const tree __z = type->type.binfo;
+ 	    if (type->type.binfo->vec.length)
+ 	    abort ();
+  type->type.binfo->vec.a[4];}
+ 	  )->vec.length);)
+     {
+       if (4 >= type->type.binfo->vec.length)
+ 	abort ();
+       blah ();
+     }
+ }
+ 
+ /* The call to blah should have been eliminated.  If the call is not
+    eliminated, then dominator optimizations failed and it'll be
+    impossible to delete other unnecessary code.  */
+ /* { dg-final { scan-tree-dump-not "blah \\(\\)" "ssa" } } */
+   
+ /* There should be two IF conditionals.  */
+ /* { dg-final { scan-tree-dump-times "if " 2 "ssa"} } */
+                                                                              

+ /* There should be a single load of type.binfo.  */
+ /* { dg-final { scan-tree-dump-times "type\\.binfo" 1 "ssa"} } */
+ 
+ /* There should be two loads of vec.length.  */
+ /* { dg-final { scan-tree-dump-times "vec.length" 2 "ssa"} } */
+ 
Index: gcc.dg/tree-ssa/20030711-1.c
===================================================================
RCS file: gcc.dg/tree-ssa/20030711-1.c
diff -N gcc.dg/tree-ssa/20030711-1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/tree-ssa/20030711-1.c	15 Jul 2003 19:23:27 -0000
***************
*** 0 ****
--- 1,53 ----
+ /* { dg-do compile */
+ /* { dg-options "-O1 -fdump-tree-ssa" } */
+  
+ 
+ union tree_node;
+ typedef union tree_node *tree;
+ struct tree_vec
+ {
+           int length;
+             tree a[1];
+ };
+ struct tree_type
+ {
+           tree binfo;
+ };
+ union tree_node
+ {
+           struct tree_type type;
+             struct tree_vec vec;
+ };
+ 
+ void
+ record_component_aliases (type)
+      tree type;
+ {
+   int i;
+   if (4 >= type->type.binfo->vec.length)
+     abort ();
+   for (; i < ((
+                 {
+                 const tree __t = type->type.binfo;
+                 if (4 >= __t->vec.length)
+                 abort (); type->type.binfo->vec.a[4];}
+               )->vec.length);)
+     {
+       if (4 >= type->type.binfo->vec.length)
+         abort ();
+       blah ();
+     }
+ }
+ 
+ /* The call to blah can not be eliminated.
+ /* { dg-final { scan-tree-dump-times "blah \\(\\)" 1 "ssa" } } */
+    
+ /* There should be three IF conditionals.  */
+ /* { dg-final { scan-tree-dump-times "if " 3 "ssa"} } */
+                                                                              

+ /* There should be two lodas of type.binfo.  */
+ /* { dg-final { scan-tree-dump-times "type\\.binfo" 2 "ssa"} } */
+  
+ /* There should be three loads of vec.length.  */
+ /* { dg-final { scan-tree-dump-times "vec.length" 3 "ssa"} } */
+ 
Index: gcc.dg/tree-ssa/20030711-2.c
===================================================================
RCS file: gcc.dg/tree-ssa/20030711-2.c
diff -N gcc.dg/tree-ssa/20030711-2.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/tree-ssa/20030711-2.c	15 Jul 2003 19:23:27 -0000
***************
*** 0 ****
--- 1,66 ----
+ /* { dg-do compile */
+ /* { dg-options "-O1 -fdump-tree-ssa" } */
+   
+ 
+ struct rtx_def;
+ typedef struct rtx_def *rtx;
+ struct rtvec_def;
+ typedef struct rtvec_def *rtvec;
+ union tree_node;
+ typedef union tree_node *tree;
+ typedef struct mem_attrs
+ {
+   long alias;
+ }
+ mem_attrs;
+ union rtunion_def
+ {
+   mem_attrs *rtmem;
+ };
+ typedef union rtunion_def rtunion;
+ struct rtx_def
+ {
+   int code;
+   rtunion fld[1];
+ };
+ struct tree_decl
+ {
+   rtx rtl;
+ };
+ union tree_node
+ {
+   struct tree_decl decl;
+ };
+ long
+ get_alias_set (t)
+      tree t;
+ {
+   if (t->decl.rtl && (((t->decl.rtl ? 0
+                         : (make_decl_rtl (t, 0), t->decl.rtl)))->code))
+     return (((((t->decl.rtl ? 0 : (make_decl_rtl (t, 0), t->decl.rtl)))->
+               fld[1]).rtmem) == 0 ? 0 : (((((
+                                                {
+                                                t;}
+                                             )->decl.
+                                             rtl ? 0 : (make_decl_rtl (t, 0),
+                                                        t->decl.rtl)))->
+                                           fld[1]).rtmem)->alias);
+ }
+ 
+ /* The calls to make_decl_rtl should be eliminated
+ /* { dg-final { scan-tree-dump-not "make_decl_rtl \\(\\)" "ssa" } } */
+     
+ /* There should be three IF conditionals.  */
+ /* { dg-final { scan-tree-dump-times "if " 3 "ssa"} } */
+                                                                              

+ /* There should be one loads of decl.rtl.  */
+ /* { dg-final { scan-tree-dump-times "decl\\.rtl" 1 "ssa"} } */
+   
+ /* There should be one load of code.  */
+ /* { dg-final { scan-tree-dump-times "code" 1 "ssa"} } */
+ 
+ /* There should be two loads of rtmem.  */
+ /* { dg-final { scan-tree-dump-times "rtmem" 2 "ssa"} } */
+ 
+ /* There should be one load of alias.  */
+ /* { dg-final { scan-tree-dump-times "->alias" 1 "ssa"} } */
Index: gcc.dg/tree-ssa/20030711-3.c
===================================================================
RCS file: gcc.dg/tree-ssa/20030711-3.c
diff -N gcc.dg/tree-ssa/20030711-3.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/tree-ssa/20030711-3.c	15 Jul 2003 19:23:27 -0000
***************
*** 0 ****
--- 1,59 ----
+ /* { dg-do compile */
+ /* { dg-options "-O1 -fdump-tree-ssa" } */
+   
+ 
+ struct rtx_def;
+ typedef struct rtx_def *rtx;
+ struct rtvec_def;
+ typedef struct rtvec_def *rtvec;
+ union tree_node;
+ typedef union tree_node *tree;
+ typedef struct mem_attrs
+ {
+   long alias;
+ }
+ mem_attrs;
+ union rtunion_def
+ {
+   mem_attrs *rtmem;
+ };
+ typedef union rtunion_def rtunion;
+ struct rtx_def
+ {
+   int code;
+   rtunion fld[1];
+ };
+ struct tree_decl
+ {
+   rtx rtl;
+ };
+ union tree_node
+ {
+   struct tree_decl decl;
+ };
+ long
+ get_alias_set (t)
+      tree t;
+ {
+   if (t->decl.rtl != (void *) 0)
+     return (((t->decl.rtl->fld[1]).rtmem) ==
+             0 ? 0
+             : ((((t->decl.
+                   rtl ? 0 : (make_decl_rtl (t, ((void *) 0)),
+                              t->decl.rtl)))->fld[1]).rtmem)->alias);
+ }
+ 
+ /* The calls to make_decl_rtl should be eliminated
+ /* { dg-final { scan-tree-dump-not "make_decl_rtl \\(\\)" "ssa" } } */
+     
+ /* There should be two IF conditionals.  */
+ /* { dg-final { scan-tree-dump-times "if " 2 "ssa"} } */
+                                                                              

+ /* There should be one load of decl.rtl.  */
+ /* { dg-final { scan-tree-dump-times "decl\\.rtl" 1 "ssa"} } */
+   
+ /* There should be two loads of rtmem.  */
+ /* { dg-final { scan-tree-dump-times "rtmem" 2 "ssa"} } */
+ 
+ /* There should be one load of alias.  */
+ /* { dg-final { scan-tree-dump-times "->alias" 1 "ssa"} } */
Index: gcc.dg/tree-ssa/20030714-1.c
===================================================================
RCS file: gcc.dg/tree-ssa/20030714-1.c
diff -N gcc.dg/tree-ssa/20030714-1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/tree-ssa/20030714-1.c	15 Jul 2003 19:23:27 -0000
***************
*** 0 ****
--- 1,44 ----
+ /* { dg-do compile */
+ /* { dg-options "-O1 -fdump-tree-ssa" } */
+    
+ struct rtx_def;
+ typedef struct rtx_def *rtx;
+ enum rtx_code
+ {
+   REG,
+   LAST_AND_UNUSED_RTX_CODE
+ };
+ typedef union rtunion_def rtunion;
+ struct rtx_def
+ {
+   enum rtx_code code:16;
+   unsigned frame_related:1;
+ };
+ static rtx
+ find_base_value (src)
+      rtx src;
+ {
+   rtx temp;
+   rtx src_0;
+   rtx src_1;
+ 
+   if ((src_0->code == REG) && (({src_0;})->frame_related))
+     return find_base_value (src_0);
+   if ((src_1->code == REG) && (({ src_1;})->frame_related))
+     return find_base_value (src_1);
+   if (src_0->code == REG)
+     find_base_value (src_0);
+   if (src_1->code == REG)
+     find_base_value (src_1);
+ }
+ 
+ 
+ /* There should be six IF conditionals.  */
+ /* { dg-final { scan-tree-dump-times "if " 6 "ssa"} } */
+ 
+ /* There should be three casts to short unsigned int.  */
+ /* { dg-final { scan-tree-dump-times "\\(short unsigned int\\)" 3 "ssa"} } */
+ 
+ /* There should be three loads of ->code
+ /* { dg-final { scan-tree-dump-times "->code" 3 "ssa"} } */
+                                                                              








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