[PATCH][1/n] Merge from match-and-simplify, public API

Richard Biener rguenther@suse.de
Mon Oct 20 11:22:00 GMT 2014


On Fri, 17 Oct 2014, Jakub Jelinek wrote:

> On Wed, Oct 15, 2014 at 01:40:07PM +0200, Richard Biener wrote:
> > 2014-10-15  Richard Biener  <rguenther@suse.de>
> > 
> > 	* gimple-fold.h (gimple_build): Declare various overloads.
> > 	(gimple_simplify): Likewise.
> > 	(gimple_convert): Re-implement in terms of gimple_build.
> > 	* gimple-fold.c (gimple_convert): Remove.
> > 	(gimple_build): New functions.
> > 
> > --- 45,141 ----
> >   extern bool arith_code_with_undefined_signed_overflow (tree_code);
> >   extern gimple_seq rewrite_to_defined_overflow (gimple);
> >   
> > ! /* gimple_build, functionally matching fold_buildN, outputs stmts
> > !    int the provided sequence, matching and simplifying them on-the-fly.
> > !    Supposed to replace force_gimple_operand (fold_buildN (...), ...).  */
> > ! tree gimple_build (gimple_seq *, location_t,
> > ! 		   enum tree_code, tree, tree,
> > ! 		   tree (*valueize) (tree) = NULL);
> 
> I find mixing prototypes with and without extern keyword weird,
> most of the prototypes in headers use extern, I think it would be cleaner
> to use it everywhere.

Fixed.

> > *** gcc/gimple-fold.c.orig	2014-10-14 15:49:30.634356179 +0200
> > --- gcc/gimple-fold.c	2014-10-15 13:02:08.158099055 +0200
> > *************** along with GCC; see the file COPYING3.
> > *** 56,61 ****
> > --- 56,62 ----
> >   #include "builtins.h"
> >   #include "output.h"
> >   
> > + 
> >   /* Return true when DECL can be referenced from current unit.
> >      FROM_DECL (if non-null) specify constructor of variable DECL was taken from.
> >      We can get declarations that are not possible to reference for various
> 
> Why the whitespace change?

Fixed.

> >   
> >   tree
> > ! gimple_convert (gimple_seq *seq, location_t loc, tree type, tree op)
> >   {
> > !   if (useless_type_conversion_p (type, TREE_TYPE (op)))
> > !     return op;
> > !   op = fold_convert_loc (loc, type, op);
> > !   gimple_seq stmts = NULL;
> > !   op = force_gimple_operand (op, &stmts, true, NULL_TREE);
> > !   gimple_seq_add_seq_without_update (seq, stmts);
> > !   return op;
> >   }
> > --- 5297,5487 ----
> >     return stmts;
> >   }
> >   
> > ! 
> > ! 
> 
> 3 lines of vertical space too much?

Reduced to two.

I moved gimple_convert out-of-line to avoid

/* ???  Forward from gimple-expr.h.  */
extern bool useless_type_conversion_p (tree, tree);

Thanks,
Richard.

2014-10-20  Richard Biener  <rguenther@suse.de>

	* gimple-fold.c (gimple_convert): Move out-of-line from ...
	* gimple-fold.h (gimple_convert): ... here.

Index: gcc/gimple-fold.c
===================================================================
--- gcc/gimple-fold.c	(revision 216459)
+++ gcc/gimple-fold.c	(working copy)
@@ -64,7 +64,6 @@ along with GCC; see the file COPYING3.
 #include "tree-eh.h"
 #include "gimple-match.h"
 
-
 /* Return true when DECL can be referenced from current unit.
    FROM_DECL (if non-null) specify constructor of variable DECL was taken from.
    We can get declarations that are not possible to reference for various
@@ -5538,7 +5537,6 @@ rewrite_to_defined_overflow (gimple stmt
 }
 
 
-
 /* Build the expression CODE OP0 of type TYPE with location LOC,
    simplifying it first if possible using VALUEIZE if not NULL.
    OP0 is expected to be valueized already.  Returns the built
@@ -5597,7 +5595,6 @@ gimple_build (gimple_seq *seq, location_
   return res;
 }
 
-
 /* Build the expression (CODE OP0 OP1 OP2) of type TYPE with location LOC,
    simplifying it first if possible using VALUEIZE if not NULL.
    OP0, OP1 and OP2 are expected to be valueized already.  Returns the built
@@ -5725,3 +5722,16 @@ gimple_build (gimple_seq *seq, location_
   return res;
 }
 
+/* Build the conversion (TYPE) OP with a result of type TYPE
+   with location LOC if such conversion is neccesary in GIMPLE,
+   simplifying it first.
+   Returns the built expression value and appends
+   statements possibly defining it to SEQ.  */
+
+tree
+gimple_convert (gimple_seq *seq, location_t loc, tree type, tree op)
+{
+  if (useless_type_conversion_p (type, TREE_TYPE (op)))
+    return op;
+  return gimple_build (seq, loc, NOP_EXPR, type, op);
+}
Index: gcc/gimple-fold.h
===================================================================
--- gcc/gimple-fold.h	(revision 216459)
+++ gcc/gimple-fold.h	(working copy)
@@ -51,54 +51,54 @@ extern gimple_seq rewrite_to_defined_ove
 /* gimple_build, functionally matching fold_buildN, outputs stmts
    int the provided sequence, matching and simplifying them on-the-fly.
    Supposed to replace force_gimple_operand (fold_buildN (...), ...).  */
-tree gimple_build (gimple_seq *, location_t,
-		   enum tree_code, tree, tree,
-		   tree (*valueize) (tree) = NULL);
+extern tree gimple_build (gimple_seq *, location_t,
+			  enum tree_code, tree, tree,
+			  tree (*valueize) (tree) = NULL);
 inline tree
 gimple_build (gimple_seq *seq,
 	      enum tree_code code, tree type, tree op0)
 {
   return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0);
 }
-tree gimple_build (gimple_seq *, location_t,
-		   enum tree_code, tree, tree, tree,
-		   tree (*valueize) (tree) = NULL);
+extern tree gimple_build (gimple_seq *, location_t,
+			  enum tree_code, tree, tree, tree,
+			  tree (*valueize) (tree) = NULL);
 inline tree
 gimple_build (gimple_seq *seq,
 	      enum tree_code code, tree type, tree op0, tree op1)
 {
   return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0, op1);
 }
-tree gimple_build (gimple_seq *, location_t,
-		   enum tree_code, tree, tree, tree, tree,
-		   tree (*valueize) (tree) = NULL);
+extern tree gimple_build (gimple_seq *, location_t,
+			  enum tree_code, tree, tree, tree, tree,
+			  tree (*valueize) (tree) = NULL);
 inline tree
 gimple_build (gimple_seq *seq,
 	      enum tree_code code, tree type, tree op0, tree op1, tree op2)
 {
   return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0, op1, op2);
 }
-tree gimple_build (gimple_seq *, location_t,
-		   enum built_in_function, tree, tree,
-		   tree (*valueize) (tree) = NULL);
+extern tree gimple_build (gimple_seq *, location_t,
+			  enum built_in_function, tree, tree,
+			  tree (*valueize) (tree) = NULL);
 inline tree
 gimple_build (gimple_seq *seq,
 	      enum built_in_function fn, tree type, tree arg0)
 {
   return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0);
 }
-tree gimple_build (gimple_seq *, location_t,
-		   enum built_in_function, tree, tree, tree,
-		   tree (*valueize) (tree) = NULL);
+extern tree gimple_build (gimple_seq *, location_t,
+			  enum built_in_function, tree, tree, tree,
+			  tree (*valueize) (tree) = NULL);
 inline tree
 gimple_build (gimple_seq *seq,
 	      enum built_in_function fn, tree type, tree arg0, tree arg1)
 {
   return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0, arg1);
 }
-tree gimple_build (gimple_seq *, location_t,
-		   enum built_in_function, tree, tree, tree, tree,
-		   tree (*valueize) (tree) = NULL);
+extern tree gimple_build (gimple_seq *, location_t,
+			  enum built_in_function, tree, tree, tree, tree,
+			  tree (*valueize) (tree) = NULL);
 inline tree
 gimple_build (gimple_seq *seq,
 	      enum built_in_function fn, tree type,
@@ -107,38 +107,25 @@ gimple_build (gimple_seq *seq,
   return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0, arg1, arg2);
 }
 
-/* ???  Forward from gimple-expr.h.  */
-extern bool useless_type_conversion_p (tree, tree);
-
-inline tree
-gimple_convert (gimple_seq *seq, location_t loc, tree type, tree op)
-{
-  if (useless_type_conversion_p (type, TREE_TYPE (op)))
-    return op;
-  return gimple_build (seq, loc, NOP_EXPR, type, op);
-}
-
+extern tree gimple_convert (gimple_seq *, location_t, tree, tree);
 inline tree
 gimple_convert (gimple_seq *seq, tree type, tree op)
 {
   return gimple_convert (seq, UNKNOWN_LOCATION, type, op);
 }
 
-/* Add gimple_seq_discard (gimple_seq *) that releases defs of all stmts
-   in the sequence.  */
-
 /* In gimple-match.c.  */
-tree gimple_simplify (enum tree_code, tree, tree,
-		      gimple_seq *, tree (*)(tree));
-tree gimple_simplify (enum tree_code, tree, tree, tree,
-		      gimple_seq *, tree (*)(tree));
-tree gimple_simplify (enum tree_code, tree, tree, tree, tree,
-		      gimple_seq *, tree (*)(tree));
-tree gimple_simplify (enum built_in_function, tree, tree,
-		      gimple_seq *, tree (*)(tree));
-tree gimple_simplify (enum built_in_function, tree, tree, tree,
-		      gimple_seq *, tree (*)(tree));
-tree gimple_simplify (enum built_in_function, tree, tree, tree, tree,
-		      gimple_seq *, tree (*)(tree));
+extern tree gimple_simplify (enum tree_code, tree, tree,
+			     gimple_seq *, tree (*)(tree));
+extern tree gimple_simplify (enum tree_code, tree, tree, tree,
+			     gimple_seq *, tree (*)(tree));
+extern tree gimple_simplify (enum tree_code, tree, tree, tree, tree,
+			     gimple_seq *, tree (*)(tree));
+extern tree gimple_simplify (enum built_in_function, tree, tree,
+			     gimple_seq *, tree (*)(tree));
+extern tree gimple_simplify (enum built_in_function, tree, tree, tree,
+			     gimple_seq *, tree (*)(tree));
+extern tree gimple_simplify (enum built_in_function, tree, tree, tree, tree,
+			     gimple_seq *, tree (*)(tree));
 
 #endif  /* GCC_GIMPLE_FOLD_H */



More information about the Gcc-patches mailing list