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]

remove unneeded fold-converts


Hi,
I've installed this patch which replaces things like
	fold_convert (some_integral_type, integer_zero_node);
with
	build_int_cst (some_integral_type, 0);

booted & tested on i686-pc-linux-gnu.

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2004-09-06  Nathan Sidwell  <nathan@codesourcery.com>

	* builtins.c (fold_builtin_strchr): Use build_int_cst, not
	fold_convert.
	(fold_builtin_strpbrk): Likewise.
	* expr.c (array_ref_low_bound): Likewise.
	* tree-scalar-evolution.c (chrec_is_positive, add_to_evolution_1,
	interpret_rhs_modify_expr, number_of_iterations_in_loop): Likewise.
	* tree-sra.c (generate_element_zero): Likewise.
	* tree-ssa-dom.c (simplify_rhs_and_lookup_avail_expr): Likewise.
	* tree-ssa-loop-ivopts.c (determine_biv_step, idx_find_step,
	add_old_iv_candidates, add_iv_candidates): Likewise.
	* tree-tailcall.c (tree_optimize_tail_calls_1): Likewise.

Index: builtins.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.c,v
retrieving revision 1.376
diff -c -3 -p -r1.376 builtins.c
*** builtins.c	4 Sep 2004 07:55:03 -0000	1.376
--- builtins.c	6 Sep 2004 13:24:55 -0000
*************** fold_builtin_strchr (tree exp, bool actu
*** 7210,7221 ****
  	  r = actually_strrchr ? strrchr (p1, c) : strchr (p1, c);
  
  	  if (r == NULL)
! 	    return fold_convert (TREE_TYPE (s1), integer_zero_node);
  
  	  /* Return an offset into the constant string argument.  */
  	  return fold (build2 (PLUS_EXPR, TREE_TYPE (s1),
! 			       s1, fold_convert (TREE_TYPE (s1),
! 						 ssize_int (r - p1))));
  	}
  
        if (actually_strrchr)
--- 7210,7220 ----
  	  r = actually_strrchr ? strrchr (p1, c) : strchr (p1, c);
  
  	  if (r == NULL)
! 	    return build_int_cst (TREE_TYPE (s1), 0);
  
  	  /* Return an offset into the constant string argument.  */
  	  return fold (build2 (PLUS_EXPR, TREE_TYPE (s1),
! 			       s1, build_int_cst (TREE_TYPE (s1), r - p1)));
  	}
  
        if (actually_strrchr)
*************** simplify_builtin_strstr (tree arglist)
*** 8645,8656 ****
  	  const char *r = strstr (p1, p2);
  
  	  if (r == NULL)
! 	    return fold_convert (TREE_TYPE (s1), integer_zero_node);
  
  	  /* Return an offset into the constant string argument.  */
  	  return fold (build2 (PLUS_EXPR, TREE_TYPE (s1),
! 			       s1, fold_convert (TREE_TYPE (s1),
! 						 ssize_int (r - p1))));
  	}
  
        if (p2[0] == '\0')
--- 8644,8654 ----
  	  const char *r = strstr (p1, p2);
  
  	  if (r == NULL)
! 	    return build_int_cst (TREE_TYPE (s1), 0);
  
  	  /* Return an offset into the constant string argument.  */
  	  return fold (build2 (PLUS_EXPR, TREE_TYPE (s1),
! 			       s1, build_int_cst (TREE_TYPE (s1), r - p1)));
  	}
  
        if (p2[0] == '\0')
*************** simplify_builtin_strchr (tree arglist)
*** 8714,8725 ****
  	  r = strchr (p1, c);
  
  	  if (r == NULL)
! 	    return fold_convert (TREE_TYPE (s1), integer_zero_node);
  
  	  /* Return an offset into the constant string argument.  */
  	  return fold (build2 (PLUS_EXPR, TREE_TYPE (s1),
! 			       s1, fold_convert (TREE_TYPE (s1),
! 						 ssize_int (r - p1))));
  	}
  
        /* FIXME: Should use here strchrM optab so that ports can optimize
--- 8712,8722 ----
  	  r = strchr (p1, c);
  
  	  if (r == NULL)
! 	    return build_int_cst (TREE_TYPE (s1), 0);
  
  	  /* Return an offset into the constant string argument.  */
  	  return fold (build2 (PLUS_EXPR, TREE_TYPE (s1),
! 			       s1, build_int_cst (TREE_TYPE (s1), r - p1)));
  	}
  
        /* FIXME: Should use here strchrM optab so that ports can optimize
*************** simplify_builtin_strrchr (tree arglist)
*** 8771,8782 ****
  	  r = strrchr (p1, c);
  
  	  if (r == NULL)
! 	    return fold_convert (TREE_TYPE (s1), integer_zero_node);
  
  	  /* Return an offset into the constant string argument.  */
  	  return fold (build2 (PLUS_EXPR, TREE_TYPE (s1),
! 			       s1, fold_convert (TREE_TYPE (s1),
! 						 ssize_int (r - p1))));
  	}
  
        if (! integer_zerop (s2))
--- 8768,8778 ----
  	  r = strrchr (p1, c);
  
  	  if (r == NULL)
! 	    return build_int_cst (TREE_TYPE (s1), 0);
  
  	  /* Return an offset into the constant string argument.  */
  	  return fold (build2 (PLUS_EXPR, TREE_TYPE (s1),
! 			       s1, build_int_cst (TREE_TYPE (s1), r - p1)));
  	}
  
        if (! integer_zerop (s2))
*************** simplify_builtin_strpbrk (tree arglist)
*** 8829,8840 ****
  	  const char *r = strpbrk (p1, p2);
  
  	  if (r == NULL)
! 	    return fold_convert (TREE_TYPE (s1), integer_zero_node);
  
  	  /* Return an offset into the constant string argument.  */
  	  return fold (build2 (PLUS_EXPR, TREE_TYPE (s1),
! 			       s1, fold_convert (TREE_TYPE (s1),
! 						 ssize_int (r - p1))));
  	}
  
        if (p2[0] == '\0')
--- 8825,8835 ----
  	  const char *r = strpbrk (p1, p2);
  
  	  if (r == NULL)
! 	    return build_int_cst (TREE_TYPE (s1), 0);
  
  	  /* Return an offset into the constant string argument.  */
  	  return fold (build2 (PLUS_EXPR, TREE_TYPE (s1),
! 			       s1, build_int_cst (TREE_TYPE (s1), r - p1)));
  	}
  
        if (p2[0] == '\0')
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.716
diff -c -3 -p -r1.716 expr.c
*** expr.c	5 Sep 2004 15:24:11 -0000	1.716
--- expr.c	6 Sep 2004 13:26:58 -0000
*************** array_ref_low_bound (tree exp)
*** 5514,5520 ****
      return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_MIN_VALUE (domain_type), exp);
  
    /* Otherwise, return a zero of the appropriate type.  */
!   return fold_convert (TREE_TYPE (TREE_OPERAND (exp, 1)), integer_zero_node);
  }
  
  /* Return a tree representing the upper bound of the array mentioned in
--- 5514,5520 ----
      return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_MIN_VALUE (domain_type), exp);
  
    /* Otherwise, return a zero of the appropriate type.  */
!   return build_int_cst (TREE_TYPE (TREE_OPERAND (exp, 1)), 0);
  }
  
  /* Return a tree representing the upper bound of the array mentioned in
Index: tree-scalar-evolution.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-scalar-evolution.c,v
retrieving revision 2.4
diff -c -3 -p -r2.4 tree-scalar-evolution.c
*** tree-scalar-evolution.c	5 Sep 2004 16:05:04 -0000	2.4
--- tree-scalar-evolution.c	6 Sep 2004 13:27:07 -0000
*************** chrec_is_positive (tree chrec, bool *val
*** 571,577 ****
  
        nb_iter = chrec_fold_minus 
  	(chrec_type (nb_iter), nb_iter,
! 	 fold_convert (chrec_type (nb_iter), integer_one_node));
  
  #if 0
        /* TODO -- If the test is after the exit, we may decrease the number of
--- 571,577 ----
  
        nb_iter = chrec_fold_minus 
  	(chrec_type (nb_iter), nb_iter,
! 	 build_int_cst (chrec_type (nb_iter), 1));
  
  #if 0
        /* TODO -- If the test is after the exit, we may decrease the number of
*************** chrec_is_positive (tree chrec, bool *val
*** 579,585 ****
        if (after_exit)
  	nb_iter = chrec_fold_minus 
  		(chrec_type (nb_iter), nb_iter,
! 		 fold_convert (chrec_type (nb_iter), integer_one_node));
  #endif
  
        end_value = chrec_apply (CHREC_VARIABLE (chrec), chrec, nb_iter);
--- 579,585 ----
        if (after_exit)
  	nb_iter = chrec_fold_minus 
  		(chrec_type (nb_iter), nb_iter,
! 		 build_int_cst (chrec_type (nb_iter), 1));
  #endif
  
        end_value = chrec_apply (CHREC_VARIABLE (chrec), chrec, nb_iter);
*************** add_to_evolution_1 (unsigned loop_nb, 
*** 704,710 ****
  	    {
  	      var = loop_nb;
  	      left = chrec_before;
! 	      right = fold_convert (type, integer_zero_node);
  	    }
  	  else
  	    {
--- 704,710 ----
  	    {
  	      var = loop_nb;
  	      left = chrec_before;
! 	      right = build_int_cst (type, 0);
  	    }
  	  else
  	    {
*************** interpret_rhs_modify_expr (struct loop *
*** 1748,1755 ****
        opnd10 = TREE_OPERAND (opnd1, 0);
        chrec10 = analyze_scalar_evolution (loop, opnd10);
        chrec10 = chrec_convert (type, chrec10);
!       res = chrec_fold_minus (type, fold_convert (type, integer_zero_node), 
! 			      chrec10);
        break;
  
      case MULT_EXPR:
--- 1748,1754 ----
        opnd10 = TREE_OPERAND (opnd1, 0);
        chrec10 = analyze_scalar_evolution (loop, opnd10);
        chrec10 = chrec_convert (type, chrec10);
!       res = chrec_fold_minus (type, build_int_cst (type, 0), chrec10);
        break;
  
      case MULT_EXPR:
*************** number_of_iterations_in_loop (struct loo
*** 2192,2198 ****
  
    type = TREE_TYPE (niter_desc.niter);
    if (integer_nonzerop (niter_desc.may_be_zero))
!     res = fold_convert (type, integer_zero_node);
    else if (integer_zerop (niter_desc.may_be_zero))
      res = niter_desc.niter;
    else
--- 2191,2197 ----
  
    type = TREE_TYPE (niter_desc.niter);
    if (integer_nonzerop (niter_desc.may_be_zero))
!     res = build_int_cst (type, 0);
    else if (integer_zerop (niter_desc.may_be_zero))
      res = niter_desc.niter;
    else
Index: tree-sra.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-sra.c,v
retrieving revision 2.28
diff -c -3 -p -r2.28 tree-sra.c
*** tree-sra.c	6 Sep 2004 10:08:04 -0000	2.28
--- tree-sra.c	6 Sep 2004 13:27:11 -0000
*************** generate_element_zero (struct sra_elt *e
*** 1537,1543 ****
        tree t;
  
        if (elt->is_scalar)
! 	t = fold_convert (elt->type, integer_zero_node);
        else
  	/* We generated a replacement for a non-scalar?  */
  	abort ();
--- 1537,1543 ----
        tree t;
  
        if (elt->is_scalar)
! 	t = build_int_cst (elt->type, 0);
        else
  	/* We generated a replacement for a non-scalar?  */
  	abort ();
Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dom.c,v
retrieving revision 2.35
diff -c -3 -p -r2.35 tree-ssa-dom.c
*** tree-ssa-dom.c	6 Sep 2004 10:08:07 -0000	2.35
--- tree-ssa-dom.c	6 Sep 2004 13:27:19 -0000
*************** simplify_rhs_and_lookup_avail_expr (stru
*** 1836,1842 ****
  	      TREE_SET_CODE (TREE_OPERAND (dummy_cond, 0), LE_EXPR);
  	      TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 0) = op;
  	      TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 1)
! 		= fold_convert (type, integer_zero_node);
  	    }
  	  val = simplify_cond_and_lookup_avail_expr (dummy_cond,
  						     &bd->avail_exprs,
--- 1836,1842 ----
  	      TREE_SET_CODE (TREE_OPERAND (dummy_cond, 0), LE_EXPR);
  	      TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 0) = op;
  	      TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 1)
! 		= build_int_cst (type, 0);
  	    }
  	  val = simplify_cond_and_lookup_avail_expr (dummy_cond,
  						     &bd->avail_exprs,
*************** simplify_rhs_and_lookup_avail_expr (stru
*** 1847,1853 ****
  	      TREE_SET_CODE (TREE_OPERAND (dummy_cond, 0), GE_EXPR);
  	      TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 0) = op;
  	      TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 1)
! 		= fold_convert (type, integer_zero_node);
  
  	      val = simplify_cond_and_lookup_avail_expr (dummy_cond,
  							 &bd->avail_exprs,
--- 1847,1853 ----
  	      TREE_SET_CODE (TREE_OPERAND (dummy_cond, 0), GE_EXPR);
  	      TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 0) = op;
  	      TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 1)
! 		= build_int_cst (type, 0);
  
  	      val = simplify_cond_and_lookup_avail_expr (dummy_cond,
  							 &bd->avail_exprs,
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.2
diff -c -3 -p -r2.2 tree-ssa-loop-ivopts.c
*** tree-ssa-loop-ivopts.c	5 Sep 2004 15:24:15 -0000	2.2
--- tree-ssa-loop-ivopts.c	6 Sep 2004 13:27:26 -0000
*************** determine_biv_step (tree phi)
*** 687,693 ****
      return NULL_TREE;
  
    if (!step)
!     return fold_convert (type, integer_zero_node);
  
    return step;
  }
--- 687,693 ----
      return NULL_TREE;
  
    if (!step)
!     return build_int_cst (type, 0);
  
    return step;
  }
*************** idx_find_step (tree base, tree *idx, voi
*** 1173,1182 ****
    if (TREE_CODE (base) == ARRAY_REF)
      step = array_ref_element_size (base);
    else
!     {
!       /* The step for pointer arithmetics already is 1 byte.  */
!       step = fold_convert (type, integer_one_node);
!     }
  
    if (TYPE_PRECISION (iv_type) < TYPE_PRECISION (type))
      iv_step = can_count_iv_in_wider_type (dta->ivopts_data->current_loop,
--- 1173,1180 ----
    if (TREE_CODE (base) == ARRAY_REF)
      step = array_ref_element_size (base);
    else
!     /* The step for pointer arithmetics already is 1 byte.  */
!     step = build_int_cst (type, 1);
  
    if (TYPE_PRECISION (iv_type) < TYPE_PRECISION (type))
      iv_step = can_count_iv_in_wider_type (dta->ivopts_data->current_loop,
*************** add_old_iv_candidates (struct ivopts_dat
*** 1585,1591 ****
  
    /* The same, but with initial value zero.  */
    add_candidate (data,
! 		 fold_convert (TREE_TYPE (iv->base), integer_zero_node),
  		 iv->step, true, NULL);
  
    phi = SSA_NAME_DEF_STMT (iv->ssa_name);
--- 1585,1591 ----
  
    /* The same, but with initial value zero.  */
    add_candidate (data,
! 		 build_int_cst (TREE_TYPE (iv->base), 0),
  		 iv->step, true, NULL);
  
    phi = SSA_NAME_DEF_STMT (iv->ssa_name);
*************** add_iv_value_candidates (struct ivopts_d
*** 1627,1634 ****
    add_candidate (data, iv->base, iv->step, false, use);
  
    /* The same, but with initial value zero.  */
!   add_candidate (data,
! 		 fold_convert (TREE_TYPE (iv->base), integer_zero_node),
  		 iv->step, false, use);
  }
  
--- 1627,1633 ----
    add_candidate (data, iv->base, iv->step, false, use);
  
    /* The same, but with initial value zero.  */
!   add_candidate (data, build_int_cst (TREE_TYPE (iv->base), 0),
  		 iv->step, false, use);
  }
  
Index: tree-tailcall.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-tailcall.c,v
retrieving revision 2.23
diff -c -3 -p -r2.23 tree-tailcall.c
*** tree-tailcall.c	6 Sep 2004 10:08:13 -0000	2.23
--- tree-tailcall.c	6 Sep 2004 13:27:28 -0000
*************** tree_optimize_tail_calls_1 (bool opt_tai
*** 875,882 ****
  	  add_referenced_tmp_var (tmp);
  
  	  phi = create_phi_node (tmp, first);
! 	  add_phi_arg (&phi, fold_convert (ret_type, integer_zero_node),
! 		       first->pred);
  	  a_acc = PHI_RESULT (phi);
  	}
  
--- 875,881 ----
  	  add_referenced_tmp_var (tmp);
  
  	  phi = create_phi_node (tmp, first);
! 	  add_phi_arg (&phi, build_int_cst (ret_type, 0), first->pred);
  	  a_acc = PHI_RESULT (phi);
  	}
  
*************** tree_optimize_tail_calls_1 (bool opt_tai
*** 888,895 ****
  	  add_referenced_tmp_var (tmp);
  
  	  phi = create_phi_node (tmp, first);
! 	  add_phi_arg (&phi, fold_convert (ret_type, integer_one_node),
! 		       first->pred);
  	  m_acc = PHI_RESULT (phi);
  	}
      }
--- 887,893 ----
  	  add_referenced_tmp_var (tmp);
  
  	  phi = create_phi_node (tmp, first);
! 	  add_phi_arg (&phi, build_int_cst (ret_type, 1), first->pred);
  	  m_acc = PHI_RESULT (phi);
  	}
      }

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