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]: cleanup for conversion exprs code patterns (9/16)


 Hi,

 this series of patches is doing small cleanup in using conversion
 expressions code patterns. There is a lot of duplicate code patterns
 for conversion expressions (CONVERT_EXPR, NOP_EXPR, NON_LVALUE_EXPR)
 that can be substituted by macro. Patterns are:
 
 (TREE_CODE (EXP) == NOP_EXPR || TREE_CODE (EXP) == CONVERT_EXPR) 
 -> TEST_CONVERT_NOPS_P(EXP)

 (TREE_CODE (EXP) == NOP_EXPR || TREE_CODE (EXP) == CONVERT_EXPR
  || TREE_CODE (EXP) == NON_LVALUE_EXPR)
 -> TEST_NOPS_P(EXP)

 case NOP_EXPR: case CONVERT_EXPR
 -> CASE_CONVERT_NOPS

 case NOP_EXPR: case CONVERT_EXPR: case NON_LVALUE_EXPR
 -> CASE_NOPS

 while (TREE_CODE (EXP) == NOP_EXPR 
        || TREE_CODE (EXP) == CONVERT_EXPR
        || TREE_CODE (EXP) == NON_LVALUE_EXPR)
    (EXP) = TREE_OPERAND (EXP, 0)
 -> STRIP_NOPS_UNSAFE(EXP)

 -> means replaced by

 Patch 1: Add new macros (TEST_CONVERT_NOPS_P(EXP), TEST_NOPS_P(EXP),
          CASE_CONVERT_NOPS, CASE_NOPS, STRIP_NOPS_UNSAFE(EXP)).
 Patch 2-4: Add support of TEST_CONVERT_NOPS_P.
 Patch 5-8: Add support of TEST_NOPS_P.
 Patch 9-11: Add support of CASE_CONVERT_NOPS.
 Patch 12-13: Add support of CASE_NOPS.
 Patch 14-16: Add support of STRIP_NOPS_UNSAFE.

 Bootstraped and tested on x86_64 x86_64 GNU/Linux.

 Ok?

 Greetings 
 Tomas


 Patch 9

 Changelog:

2008-03-13  Tomas Bily  <tbily@suse.cz>

	* tree-cfg.c (verify_gimple_expr): Use CASE_CONVERT_NOPS.

	* c-common.c (c_common_truthvalue_conversion): Likewise.

	* varasm.c (initializer_constant_valid_p): Likewise.

	* c-omp.c (check_omp_for_incr_expr): Likewise.

	* gimplify.c (gimplify_expr): Likewise.

	* tree-vectorizer.c (supportable_widening_operation)
	(supportable_narrowing_operation): Likewise.

	* c-pretty-print.c (pp_c_cast_expression, pp_c_expression): Likewise.

	* matrix-reorg.c (can_calculate_expr_before_stmt): Likewise.

	* dwarf2out.c (descr_info_loc): Likewise.

	* typeck.c (is_bitfield_expr_with_lowered_type, build_unary_op): Likewise.

	* fold-const.c (operand_equal_p, fold_unary): Likewise.

	* tree-scalar-evolution.c (interpret_rhs_modify_stmt): Likewise.

	* tree.c (stabilize_reference): Likewise.

	* tree-pretty-print.c (dump_generic_node, op_prio): Likewise.

	* tree-ssa-loop-niter.c (derive_constant_upper_bound): Likewise.



Index: gcc/tree-ssa-loop-niter.c
===================================================================
--- gcc/tree-ssa-loop-niter.c	(revision 132974)
+++ gcc/tree-ssa-loop-niter.c	(working copy)
@@ -2190,8 +2189,7 @@ derive_constant_upper_bound (const_tree 
     case INTEGER_CST:
       return tree_to_double_int (val);
 
-    case NOP_EXPR:
-    case CONVERT_EXPR:
+    CASE_CONVERT_NOPS:
       op0 = TREE_OPERAND (val, 0);
       subtype = TREE_TYPE (op0);
       if (!TYPE_UNSIGNED (subtype)
Index: gcc/tree-pretty-print.c
===================================================================
--- gcc/tree-pretty-print.c	(revision 132974)
+++ gcc/tree-pretty-print.c	(working copy)
@@ -1421,8 +1421,7 @@ dump_generic_node (pretty_printer *buffe
     case FIXED_CONVERT_EXPR:
     case FIX_TRUNC_EXPR:
     case FLOAT_EXPR:
-    case CONVERT_EXPR:
-    case NOP_EXPR:
+    CASE_CONVERT_NOPS:
       type = TREE_TYPE (node);
       op0 = TREE_OPERAND (node, 0);
       if (type != TREE_TYPE (op0))
@@ -2441,8 +2440,7 @@ op_prio (const_tree op)
     case INDIRECT_REF:
     case ADDR_EXPR:
     case FLOAT_EXPR:
-    case NOP_EXPR:
-    case CONVERT_EXPR:
+    CASE_CONVERT_NOPS:
     case FIX_TRUNC_EXPR:
     case TARGET_EXPR:
       return 14;
Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 132974)
+++ gcc/tree.c	(working copy)
@@ -2729,8 +2726,7 @@ stabilize_reference (tree ref)
       /* No action is needed in this case.  */
       return ref;
 
-    case NOP_EXPR:
-    case CONVERT_EXPR:
+    CASE_CONVERT_NOPS:
     case FLOAT_EXPR:
     case FIX_TRUNC_EXPR:
       result = build_nt (code, stabilize_reference (TREE_OPERAND (ref, 0)));
Index: gcc/tree-scalar-evolution.c
===================================================================
--- gcc/tree-scalar-evolution.c	(revision 132974)
+++ gcc/tree-scalar-evolution.c	(working copy)
@@ -1675,8 +1675,7 @@ interpret_rhs_modify_stmt (struct loop *
 			   at_stmt);
       break;
       
-    case NOP_EXPR:
-    case CONVERT_EXPR:
+    CASE_CONVERT_NOPS:
       opnd10 = TREE_OPERAND (opnd1, 0);
       chrec10 = analyze_scalar_evolution (loop, opnd10);
       res = chrec_convert (type, chrec10, at_stmt);
Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c	(revision 132974)
+++ gcc/fold-const.c	(working copy)
@@ -3160,8 +3160,7 @@ operand_equal_p (const_tree arg0, const_
       /* Two conversions are equal only if signedness and modes match.  */
       switch (TREE_CODE (arg0))
         {
-        case NOP_EXPR:
-        case CONVERT_EXPR:
+	CASE_CONVERT_NOPS:
         case FIX_TRUNC_EXPR:
 	  if (TYPE_UNSIGNED (TREE_TYPE (arg0))
 	      != TYPE_UNSIGNED (TREE_TYPE (arg1)))
@@ -7701,9 +7696,8 @@ fold_unary (enum tree_code code, tree ty
 	return fold_convert (type, op0);
       return NULL_TREE;
 
-    case NOP_EXPR:
+    CASE_CONVERT_NOPS:
     case FLOAT_EXPR:
-    case CONVERT_EXPR:
     case FIX_TRUNC_EXPR:
       if (TREE_TYPE (op0) == type)
 	return op0;
Index: gcc/cp/typeck.c
===================================================================
--- gcc/cp/typeck.c	(revision 132974)
+++ gcc/cp/typeck.c	(working copy)
@@ -1481,8 +1481,7 @@ is_bitfield_expr_with_lowered_type (cons
 	return DECL_BIT_FIELD_TYPE (field);
       }
 
-    case NOP_EXPR:
-    case CONVERT_EXPR:
+    CASE_CONVERT_NOPS:
       if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (exp, 0)))
 	  == TYPE_MAIN_VARIANT (TREE_TYPE (exp)))
 	return is_bitfield_expr_with_lowered_type (TREE_OPERAND (exp, 0));
@@ -4445,8 +4443,7 @@ build_unary_op (enum tree_code code, tre
 
       switch (TREE_CODE (arg))
 	{
-	case NOP_EXPR:
-	case CONVERT_EXPR:
+	CASE_CONVERT_NOPS:
 	case FLOAT_EXPR:
 	case FIX_TRUNC_EXPR:
 	  if (! lvalue_p (arg) && pedantic)
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 132974)
+++ gcc/dwarf2out.c	(working copy)
@@ -11720,8 +11716,7 @@ descr_info_loc (tree val, tree base_decl
 
   switch (TREE_CODE (val))
     {
-    case NOP_EXPR:
-    case CONVERT_EXPR:
+    CASE_CONVERT_NOPS:
       return descr_info_loc (TREE_OPERAND (val, 0), base_decl);
     case INTEGER_CST:
       if (host_integerp (val, 0))
Index: gcc/matrix-reorg.c
===================================================================
--- gcc/matrix-reorg.c	(revision 132974)
+++ gcc/matrix-reorg.c	(working copy)
@@ -1442,8 +1442,7 @@ can_calculate_expr_before_stmt (tree exp
 	  }
 	return res;
       }
-    case NOP_EXPR:
-    case CONVERT_EXPR:
+    CASE_CONVERT_NOPS:
       res = can_calculate_expr_before_stmt (TREE_OPERAND (expr, 0), visited);
       if (res != NULL_TREE)
 	return build1 (TREE_CODE (expr), TREE_TYPE (expr), res);
Index: gcc/c-pretty-print.c
===================================================================
--- gcc/c-pretty-print.c	(revision 132974)
+++ gcc/c-pretty-print.c	(working copy)
@@ -1553,8 +1553,7 @@ pp_c_cast_expression (c_pretty_printer *
     {
     case FLOAT_EXPR:
     case FIX_TRUNC_EXPR:
-    case CONVERT_EXPR:
-    case NOP_EXPR:
+    CASE_CONVERT_NOPS:
       pp_c_type_cast (pp, TREE_TYPE (e));
       pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
       break;
@@ -1945,8 +1944,7 @@ pp_c_expression (c_pretty_printer *pp, t
 
     case FLOAT_EXPR:
     case FIX_TRUNC_EXPR:
-    case CONVERT_EXPR:
-    case NOP_EXPR:
+    CASE_CONVERT_NOPS:
       pp_c_cast_expression (pp, e);
       break;
 
Index: gcc/tree-vectorizer.c
===================================================================
--- gcc/tree-vectorizer.c	(revision 132974)
+++ gcc/tree-vectorizer.c	(working copy)
@@ -2165,8 +2165,7 @@ supportable_widening_operation (enum tre
         }
       break;
 
-    case NOP_EXPR:
-    case CONVERT_EXPR:
+    CASE_CONVERT_NOPS:
       if (BYTES_BIG_ENDIAN)
         {
           c1 = VEC_UNPACK_HI_EXPR;
@@ -2260,8 +2259,7 @@ supportable_narrowing_operation (enum tr
 
   switch (code)
     {
-    case NOP_EXPR:
-    case CONVERT_EXPR:
+    CASE_CONVERT_NOPS:
       c1 = VEC_PACK_TRUNC_EXPR;
       break;
 
Index: gcc/gimplify.c
===================================================================
--- gcc/gimplify.c	(revision 132974)
+++ gcc/gimplify.c	(working copy)
@@ -5736,8 +5731,7 @@ gimplify_expr (tree *expr_p, tree *pre_p
 	  ret = gimplify_va_arg_expr (expr_p, pre_p, post_p);
 	  break;
 
-	case CONVERT_EXPR:
-	case NOP_EXPR:
+	CASE_CONVERT_NOPS:
 	  if (IS_EMPTY_STMT (*expr_p))
 	    {
 	      ret = GS_ALL_DONE;
Index: gcc/c-omp.c
===================================================================
--- gcc/c-omp.c	(revision 132974)
+++ gcc/c-omp.c	(working copy)
@@ -171,8 +171,7 @@ check_omp_for_incr_expr (tree exp, tree 
 
   switch (TREE_CODE (exp))
     {
-    case NOP_EXPR:
-    case CONVERT_EXPR:
+    CASE_CONVERT_NOPS:
       t = check_omp_for_incr_expr (TREE_OPERAND (exp, 0), decl);
       if (t != error_mark_node)
         return fold_convert (TREE_TYPE (exp), t);
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c	(revision 132974)
+++ gcc/varasm.c	(working copy)
@@ -4094,8 +4084,7 @@ initializer_constant_valid_p (tree value
     case NON_LVALUE_EXPR:
       return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
 
-    case CONVERT_EXPR:
-    case NOP_EXPR:
+    CASE_CONVERT_NOPS:
       {
 	tree src;
 	tree src_type;
Index: gcc/c-common.c
===================================================================
--- gcc/c-common.c	(revision 132974)
+++ gcc/c-common.c	(working copy)
@@ -3036,8 +3036,7 @@ c_common_truthvalue_conversion (tree exp
 		c_common_truthvalue_conversion (TREE_OPERAND (expr, 1)),
 		c_common_truthvalue_conversion (TREE_OPERAND (expr, 2)));
 
-    case CONVERT_EXPR:
-    case NOP_EXPR:
+    CASE_CONVERT_NOPS:
       /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
 	 since that affects how `default_conversion' will behave.  */
       if (TREE_CODE (TREE_TYPE (expr)) == REFERENCE_TYPE
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c	(revision 132974)
+++ gcc/tree-cfg.c	(working copy)
@@ -3595,8 +3593,7 @@ verify_gimple_expr (tree expr)
   /* Special codes we cannot handle via their class.  */
   switch (TREE_CODE (expr))
     {
-    case NOP_EXPR:
-    case CONVERT_EXPR:
+    CASE_CONVERT_NOPS:
       {
 	tree op = TREE_OPERAND (expr, 0);
 	if (!is_gimple_val (op))


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