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: NON_LVALUE_EXPR cleanup


Hi,

 this patch remove all (hope) occurrences of NON_LVALUE_EXPR that is
unreachable after gimplification as it was suggested by
http://gcc.gnu.org/ml/gcc-patches/2008-03/msg01990.html. There are few
occurrences of NON_LVALUE_EXPR after gimplification that can not be
removed (namely varasm.c) becuase not all expresions are gimplified
(this exception are expresions for initial value of global variables).

Bootstraped and tested on x86_64-linux, i686-linux, ppc-linux,
ia64-linux.

Ok ?

 Greetings
 Tomas

Changelog:

2008-04-22  Tomas Bily  <tbily@suse.cz>

	* tree-cfg.c (verify_expr): Check for NON_LVALUE_EXPR as unreachable
	case.

	* tree-vrp.c (extract_range_from_unary_expr): Removed unused
	NON_LVALUE_EXPR.

	* tree-ssa-threadedge.c (simplify_control_stmt_condition): Likewise.
	
	* tree-ssa-structalias.c (get_constraint_for): Likewise.

	* tree-inline.c (estimate_num_insns_1): Likewise.

	* varasm.c (const_hash_1, compare_constant, copy_constant)
	(compute_reloc_for_constant, output_addressed_constants): Likewise.

	* emit-rtl.c (component_ref_for_mem_expr)
	(set_mem_attributes_minus_bitpos): Likewise.

	* expr.c (highest_pow2_factor, expand_expr_real_1, )
	(is_aligning_offset): Likewise.

	* dwarf2out.c (loc_descriptor_from_tree_1, add_bound_info): Likewise.

	* tree-ssa-loop-ivopts.c (may_be_nonaddressable_p): Likewise.

	* dojump.c (do_jump): Likewise.

	* builtins.c (get_pointer_alignment, get_memory_rtx)
	(integer_valued_real_p, fold_builtin_next_arg): Likewise.

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


Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c	(revision 133827)
+++ gcc/tree-vrp.c	(working copy)
@@ -2286,7 +2286,6 @@ extract_range_from_unary_expr (value_ran
   if (code == FIX_TRUNC_EXPR
       || code == FLOAT_EXPR
       || code == BIT_NOT_EXPR
-      || code == NON_LVALUE_EXPR
       || code == CONJ_EXPR)
     {
       set_value_range_to_varying (vr);
@@ -3961,8 +3960,7 @@ register_edge_assert_for_1 (tree op, enu
       retval |= register_edge_assert_for_1 (rhs, code, e, bsi);
     }
   else if (TREE_CODE (rhs) == NOP_EXPR
-	   || TREE_CODE (rhs) == CONVERT_EXPR
-	   || TREE_CODE (rhs) == NON_LVALUE_EXPR)
+	   || TREE_CODE (rhs) == CONVERT_EXPR)
     { 
       /* Recurse through the type conversion.  */
       retval |= register_edge_assert_for_1 (TREE_OPERAND (rhs, 0),
Index: gcc/tree-scalar-evolution.c
===================================================================
--- gcc/tree-scalar-evolution.c	(revision 133827)
+++ gcc/tree-scalar-evolution.c	(working copy)
@@ -2117,7 +2117,6 @@ instantiate_parameters_1 (struct loop *l
 
     case NOP_EXPR:
     case CONVERT_EXPR:
-    case NON_LVALUE_EXPR:
       op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
 				      flags, cache, size_expr);
       if (op0 == chrec_dont_know)
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	(revision 133827)
+++ gcc/builtins.c	(working copy)
@@ -281,7 +281,6 @@ get_pointer_alignment (tree exp, unsigne
 	{
 	case NOP_EXPR:
 	case CONVERT_EXPR:
-	case NON_LVALUE_EXPR:
 	  exp = TREE_OPERAND (exp, 0);
 	  if (! POINTER_TYPE_P (TREE_TYPE (exp)))
 	    return align;
@@ -1073,8 +1072,7 @@ get_memory_rtx (tree exp, tree len)
   /* Get an expression we can use to find the attributes to assign to MEM.
      If it is an ADDR_EXPR, use the operand.  Otherwise, dereference it if
      we can.  First remove any nops.  */
-  while ((TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR
-	  || TREE_CODE (exp) == NON_LVALUE_EXPR)
+  while ((TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR)
 	 && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (exp, 0))))
     exp = TREE_OPERAND (exp, 0);
 
@@ -1106,7 +1104,6 @@ get_memory_rtx (tree exp, tree len)
 	  while (TREE_CODE (inner) == ARRAY_REF
 		 || TREE_CODE (inner) == NOP_EXPR
 		 || TREE_CODE (inner) == CONVERT_EXPR
-		 || TREE_CODE (inner) == NON_LVALUE_EXPR
 		 || TREE_CODE (inner) == VIEW_CONVERT_EXPR
 		 || TREE_CODE (inner) == SAVE_EXPR)
 	    inner = TREE_OPERAND (inner, 0);
@@ -7262,7 +7259,6 @@ integer_valued_real_p (tree t)
 
     case ABS_EXPR:
     case SAVE_EXPR:
-    case NON_LVALUE_EXPR:
       return integer_valued_real_p (TREE_OPERAND (t, 0));
 
     case COMPOUND_EXPR:
@@ -11432,7 +11428,6 @@ fold_builtin_next_arg (tree exp, bool va
 	 parameters.  */
       while (TREE_CODE (arg) == NOP_EXPR
 	     || TREE_CODE (arg) == CONVERT_EXPR
-	     || TREE_CODE (arg) == NON_LVALUE_EXPR
 	     || TREE_CODE (arg) == INDIRECT_REF)
 	arg = TREE_OPERAND (arg, 0);
       if (arg != last_parm)
Index: gcc/dojump.c
===================================================================
--- gcc/dojump.c	(revision 133827)
+++ gcc/dojump.c	(working copy)
@@ -219,8 +219,7 @@ do_jump (tree exp, rtx if_false_label, r
 
 	  /* Strip narrowing integral type conversions.  */
 	  while ((TREE_CODE (exp0) == NOP_EXPR
-		  || TREE_CODE (exp0) == CONVERT_EXPR
-		  || TREE_CODE (exp0) == NON_LVALUE_EXPR)
+		  || TREE_CODE (exp0) == CONVERT_EXPR)
 		 && TREE_OPERAND (exp0, 0) != error_mark_node
 		 && TYPE_PRECISION (TREE_TYPE (exp0))
 		    <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp0, 0))))
Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c	(revision 133827)
+++ gcc/tree-ssa-loop-ivopts.c	(working copy)
@@ -1541,7 +1541,6 @@ may_be_nonaddressable_p (tree expr)
       return may_be_nonaddressable_p (TREE_OPERAND (expr, 0));
 
     case CONVERT_EXPR:
-    case NON_LVALUE_EXPR:
     case NOP_EXPR:
       return true;
 
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 133827)
+++ gcc/dwarf2out.c	(working copy)
@@ -9582,7 +9582,6 @@ loc_descriptor_from_tree_1 (tree loc, in
 
     case NOP_EXPR:
     case CONVERT_EXPR:
-    case NON_LVALUE_EXPR:
     case VIEW_CONVERT_EXPR:
     case SAVE_EXPR:
     case GIMPLE_MODIFY_STMT:
@@ -11211,7 +11210,6 @@ add_bound_info (dw_die_ref subrange_die,
 
     case CONVERT_EXPR:
     case NOP_EXPR:
-    case NON_LVALUE_EXPR:
     case VIEW_CONVERT_EXPR:
       add_bound_info (subrange_die, bound_attr, TREE_OPERAND (bound, 0));
       break;
Index: gcc/expr.c
===================================================================
--- gcc/expr.c	(revision 133827)
+++ gcc/expr.c	(working copy)
@@ -6599,7 +6599,7 @@ highest_pow2_factor (const_tree exp)
 	}
       break;
 
-    case NON_LVALUE_EXPR:  case NOP_EXPR:  case CONVERT_EXPR:
+    case NOP_EXPR:  case CONVERT_EXPR:
     case SAVE_EXPR:
       return highest_pow2_factor (TREE_OPERAND (exp, 0));
 
@@ -7154,9 +7154,8 @@ expand_expr_real_1 (tree exp, rtx target
     }
 
   ignore = (target == const0_rtx
-	    || ((code == NON_LVALUE_EXPR || code == NOP_EXPR
-		 || code == CONVERT_EXPR || code == COND_EXPR
-		 || code == VIEW_CONVERT_EXPR)
+	    || ((code == NOP_EXPR || code == CONVERT_EXPR 
+		 || code == COND_EXPR || code == VIEW_CONVERT_EXPR)
 		&& TREE_CODE (type) == VOID_TYPE));
 
   /* An operation in what may be a bit-field type needs the
@@ -8051,7 +8050,6 @@ expand_expr_real_1 (tree exp, rtx target
       return expand_call (exp, target, ignore);
 
     case PAREN_EXPR:
-    case NON_LVALUE_EXPR:
     case NOP_EXPR:
     case CONVERT_EXPR:
       if (TREE_OPERAND (exp, 0) == error_mark_node)
@@ -9444,8 +9442,7 @@ static int
 is_aligning_offset (const_tree offset, const_tree exp)
 {
   /* Strip off any conversions.  */
-  while (TREE_CODE (offset) == NON_LVALUE_EXPR
-	 || TREE_CODE (offset) == NOP_EXPR
+  while (TREE_CODE (offset) == NOP_EXPR
 	 || TREE_CODE (offset) == CONVERT_EXPR)
     offset = TREE_OPERAND (offset, 0);
 
@@ -9461,8 +9458,7 @@ is_aligning_offset (const_tree offset, c
   /* Look at the first operand of BIT_AND_EXPR and strip any conversion.
      It must be NEGATE_EXPR.  Then strip any more conversions.  */
   offset = TREE_OPERAND (offset, 0);
-  while (TREE_CODE (offset) == NON_LVALUE_EXPR
-	 || TREE_CODE (offset) == NOP_EXPR
+  while (TREE_CODE (offset) == NOP_EXPR
 	 || TREE_CODE (offset) == CONVERT_EXPR)
     offset = TREE_OPERAND (offset, 0);
 
@@ -9470,8 +9466,7 @@ is_aligning_offset (const_tree offset, c
     return 0;
 
   offset = TREE_OPERAND (offset, 0);
-  while (TREE_CODE (offset) == NON_LVALUE_EXPR
-	 || TREE_CODE (offset) == NOP_EXPR
+  while (TREE_CODE (offset) == NOP_EXPR
 	 || TREE_CODE (offset) == CONVERT_EXPR)
     offset = TREE_OPERAND (offset, 0);
 
Index: gcc/emit-rtl.c
===================================================================
--- gcc/emit-rtl.c	(revision 133827)
+++ gcc/emit-rtl.c	(working copy)
@@ -1411,7 +1411,6 @@ component_ref_for_mem_expr (tree ref)
       /* Now remove any conversions: they don't change what the underlying
 	 object is.  Likewise for SAVE_EXPR.  */
       while (TREE_CODE (inner) == NOP_EXPR || TREE_CODE (inner) == CONVERT_EXPR
-	     || TREE_CODE (inner) == NON_LVALUE_EXPR
 	     || TREE_CODE (inner) == VIEW_CONVERT_EXPR
 	     || TREE_CODE (inner) == SAVE_EXPR)
 	inner = TREE_OPERAND (inner, 0);
@@ -1542,7 +1541,6 @@ set_mem_attributes_minus_bitpos (rtx ref
       /* Now remove any conversions: they don't change what the underlying
 	 object is.  Likewise for SAVE_EXPR.  */
       while (TREE_CODE (t) == NOP_EXPR || TREE_CODE (t) == CONVERT_EXPR
-	     || TREE_CODE (t) == NON_LVALUE_EXPR
 	     || TREE_CODE (t) == VIEW_CONVERT_EXPR
 	     || TREE_CODE (t) == SAVE_EXPR)
 	t = TREE_OPERAND (t, 0);
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c	(revision 133827)
+++ gcc/varasm.c	(working copy)
@@ -2815,7 +2815,6 @@ const_hash_1 (const tree exp)
 
     case NOP_EXPR:
     case CONVERT_EXPR:
-    case NON_LVALUE_EXPR:
       return const_hash_1 (TREE_OPERAND (exp, 0)) * 7 + 2;
 
     default:
@@ -2970,7 +2969,6 @@ compare_constant (const tree t1, const t
 
     case NOP_EXPR:
     case CONVERT_EXPR:
-    case NON_LVALUE_EXPR:
     case VIEW_CONVERT_EXPR:
       return compare_constant (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
 
@@ -3018,7 +3016,6 @@ copy_constant (tree exp)
 
     case NOP_EXPR:
     case CONVERT_EXPR:
-    case NON_LVALUE_EXPR:
     case VIEW_CONVERT_EXPR:
       return build1 (TREE_CODE (exp), TREE_TYPE (exp),
 		     copy_constant (TREE_OPERAND (exp, 0)));
@@ -3917,7 +3914,6 @@ compute_reloc_for_constant (tree exp)
 
     case NOP_EXPR:
     case CONVERT_EXPR:
-    case NON_LVALUE_EXPR:
     case VIEW_CONVERT_EXPR:
       reloc = compute_reloc_for_constant (TREE_OPERAND (exp, 0));
       break;
@@ -3973,7 +3969,6 @@ output_addressed_constants (tree exp)
 
     case NOP_EXPR:
     case CONVERT_EXPR:
-    case NON_LVALUE_EXPR:
     case VIEW_CONVERT_EXPR:
       output_addressed_constants (TREE_OPERAND (exp, 0));
       break;
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c	(revision 133827)
+++ gcc/tree-inline.c	(working copy)
@@ -2235,7 +2235,6 @@ estimate_num_insns_1 (tree *tp, int *wal
     case EH_FILTER_EXPR:
     case STATEMENT_LIST:
     case ERROR_MARK:
-    case NON_LVALUE_EXPR:
     case FDESC_EXPR:
     case VA_ARG_EXPR:
     case TRY_CATCH_EXPR:
Index: gcc/tree-ssa-structalias.c
===================================================================
--- gcc/tree-ssa-structalias.c	(revision 133827)
+++ gcc/tree-ssa-structalias.c	(working copy)
@@ -2913,7 +2913,6 @@ get_constraint_for (tree t, VEC (ce_s, h
 	  {
 	  case NOP_EXPR:
 	  case CONVERT_EXPR:
-	  case NON_LVALUE_EXPR:
 	    {
 	      tree op = TREE_OPERAND (t, 0);
 
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c	(revision 133827)
+++ gcc/tree-cfg.c	(working copy)
@@ -3222,6 +3222,9 @@ verify_expr (tree *tp, int *walk_subtree
 	}
       break;
 
+    case NON_LVALUE_EXPR:
+	gcc_unreachable ();
+
     case NOP_EXPR:
     case CONVERT_EXPR:
     case FIX_TRUNC_EXPR:
@@ -3229,7 +3232,6 @@ verify_expr (tree *tp, int *walk_subtree
     case NEGATE_EXPR:
     case ABS_EXPR:
     case BIT_NOT_EXPR:
-    case NON_LVALUE_EXPR:
     case TRUTH_NOT_EXPR:
       CHECK_OP (0, "invalid operand to unary operator");
       break;
Index: gcc/tree-ssa-threadedge.c
===================================================================
--- gcc/tree-ssa-threadedge.c	(revision 133827)
+++ gcc/tree-ssa-threadedge.c	(working copy)
@@ -429,8 +429,7 @@ simplify_control_stmt_condition (edge e,
 
       cached_lhs = fold (COND_EXPR_COND (dummy_cond));
       while (TREE_CODE (cached_lhs) == NOP_EXPR
-	     || TREE_CODE (cached_lhs) == CONVERT_EXPR
-	     || TREE_CODE (cached_lhs) == NON_LVALUE_EXPR)
+	     || TREE_CODE (cached_lhs) == CONVERT_EXPR)
 	cached_lhs = TREE_OPERAND (cached_lhs, 0);
 
       fold_undefer_overflow_warnings (is_gimple_min_invariant (cached_lhs),


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