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] Remove unused tree codes, FIX_CEIL_EXPR, FIX_FLOOR_EXPR, FIX_ROUND_EXPR


This patch removes the three unused tree-codes FIX_CEIL_EXPR, 
FIX_FLOOR_EXPR, FIX_ROUND_EXPR.  The only "user" was the fortran frontend
which used them internally (but never created trees with that codes).

So I guess at least the fortran guys should ack this apart from a 
middle-end maintainer.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Ok for mainline?

Thanks,
Richard.

:ADDPATCH middle-end, fortran:

2006-11-10  Richard Guenther  <rguenther@suse.de>

	* tree.def (FIX_CEIL_EXPR, FIX_FLOOR_EXPR, FIX_ROUND_EXPR):
	Remove unused tree codes.
	* tree-vrp.c (extract_range_from_unary_expr): Remove handling
	of FIX_CEIL_EXPR, FIX_FLOOR_EXPR and FIX_ROUND_EXPR.
	* tree-pretty-print.c (dump_generic_node, op_prio): Likewise.
	* tree.c (stabilize_reference): Likewise.
	* fold-const.c (fold_convert_const_int_from_real, operand_equal_p,
	fold_unary): Likewise.
	* tree-gimple.c (is_gimple_cast): Likewise.
	* dwarf2out.c (loc_descriptor_from_tree_1): Likewise.
	* expr.c (expand_expr_real_1): Likewise.
	* tree-eh.c (tree_could_trap_p): Likewise.
	* gimplify.c (gimplify_expr): Likewise.
	* tree-inline.c (estimate_num_insns_1): Likewise.
	* tree-cfg.c (verify_expr): Likewise.

	cp/
	* typeck.c (build_unary_op): Likewise.

	java/
	* check-init.c (check_init): Likewise.

	ada/
	* trans.c (maybe_stabilize_reference): Likewise.

	fortran/
	* trans-intrinsic.c (enum rounding_mode): New enum.
	(build_fix_expr, gfc_conv_intrinsic_aint, gfc_conv_intrinsic_mod,
	gfc_conv_intrinsic_function): Use it instead of FIX_CEIL_EXPR,
	FIX_FLOOR_EXPR, FIX_ROUND_EXPR and FIX_TRUNC_EXPR.


Index: tree-vrp.c
===================================================================
*** tree-vrp.c	(revision 118652)
--- tree-vrp.c	(working copy)
*************** extract_range_from_unary_expr (value_ran
*** 1596,1604 ****
    /* Refuse to operate on certain unary expressions for which we
       cannot easily determine a resulting range.  */
    if (code == FIX_TRUNC_EXPR
-       || code == FIX_CEIL_EXPR
-       || code == FIX_FLOOR_EXPR
-       || code == FIX_ROUND_EXPR
        || code == FLOAT_EXPR
        || code == BIT_NOT_EXPR
        || code == NON_LVALUE_EXPR
--- 1596,1601 ----
Index: tree-pretty-print.c
===================================================================
*** tree-pretty-print.c	(revision 118652)
--- tree-pretty-print.c	(working copy)
*************** dump_generic_node (pretty_printer *buffe
*** 1324,1332 ****
        break;
  
      case FIX_TRUNC_EXPR:
-     case FIX_CEIL_EXPR:
-     case FIX_FLOOR_EXPR:
-     case FIX_ROUND_EXPR:
      case FLOAT_EXPR:
      case CONVERT_EXPR:
      case NOP_EXPR:
--- 1324,1329 ----
*************** op_prio (tree op)
*** 2236,2244 ****
      case NOP_EXPR:
      case CONVERT_EXPR:
      case FIX_TRUNC_EXPR:
-     case FIX_CEIL_EXPR:
-     case FIX_FLOOR_EXPR:
-     case FIX_ROUND_EXPR:
      case TARGET_EXPR:
        return 14;
  
--- 2233,2238 ----
Index: java/check-init.c
===================================================================
*** java/check-init.c	(revision 118652)
--- java/check-init.c	(working copy)
*************** check_init (tree exp, words before)
*** 814,822 ****
      case ADDR_EXPR:
      case NON_LVALUE_EXPR:
      case INSTANCEOF_EXPR:
-     case FIX_CEIL_EXPR:
-     case FIX_FLOOR_EXPR:
-     case FIX_ROUND_EXPR:
      case ABS_EXPR:
        /* Avoid needless recursion. */
        exp = TREE_OPERAND (exp, 0);
--- 814,819 ----
Index: tree.c
===================================================================
*** tree.c	(revision 118652)
--- tree.c	(working copy)
*************** stabilize_reference (tree ref)
*** 2595,2603 ****
      case CONVERT_EXPR:
      case FLOAT_EXPR:
      case FIX_TRUNC_EXPR:
-     case FIX_FLOOR_EXPR:
-     case FIX_ROUND_EXPR:
-     case FIX_CEIL_EXPR:
        result = build_nt (code, stabilize_reference (TREE_OPERAND (ref, 0)));
        break;
  
--- 2595,2600 ----
Index: fold-const.c
===================================================================
*** fold-const.c	(revision 118652)
--- fold-const.c	(working copy)
*************** fold_convert_const_int_from_real (enum t
*** 1859,1876 ****
        real_trunc (&r, VOIDmode, &x);
        break;
  
-     case FIX_CEIL_EXPR:
-       real_ceil (&r, VOIDmode, &x);
-       break;
- 
-     case FIX_FLOOR_EXPR:
-       real_floor (&r, VOIDmode, &x);
-       break;
- 
-     case FIX_ROUND_EXPR:
-       real_round (&r, VOIDmode, &x);
-       break;
- 
      default:
        gcc_unreachable ();
      }
--- 1859,1864 ----
*************** operand_equal_p (tree arg0, tree arg1, u
*** 2617,2626 ****
          {
          case NOP_EXPR:
          case CONVERT_EXPR:
-         case FIX_CEIL_EXPR:
          case FIX_TRUNC_EXPR:
-         case FIX_FLOOR_EXPR:
-         case FIX_ROUND_EXPR:
  	  if (TYPE_UNSIGNED (TREE_TYPE (arg0))
  	      != TYPE_UNSIGNED (TREE_TYPE (arg1)))
  	    return 0;
--- 2605,2611 ----
*************** fold_unary (enum tree_code code, tree ty
*** 7306,7314 ****
      case FLOAT_EXPR:
      case CONVERT_EXPR:
      case FIX_TRUNC_EXPR:
-     case FIX_CEIL_EXPR:
-     case FIX_FLOOR_EXPR:
-     case FIX_ROUND_EXPR:
        if (TREE_TYPE (op0) == type)
  	return op0;
        
--- 7291,7296 ----
Index: tree-gimple.c
===================================================================
*** tree-gimple.c	(revision 118652)
--- tree-gimple.c	(working copy)
*************** is_gimple_cast (tree t)
*** 409,418 ****
  {
    return (TREE_CODE (t) == NOP_EXPR
  	  || TREE_CODE (t) == CONVERT_EXPR
!           || TREE_CODE (t) == FIX_TRUNC_EXPR
!           || TREE_CODE (t) == FIX_CEIL_EXPR
!           || TREE_CODE (t) == FIX_FLOOR_EXPR
!           || TREE_CODE (t) == FIX_ROUND_EXPR);
  }
  
  /* Return true if T is a valid op0 of a CALL_EXPR.  */
--- 409,415 ----
  {
    return (TREE_CODE (t) == NOP_EXPR
  	  || TREE_CODE (t) == CONVERT_EXPR
!           || TREE_CODE (t) == FIX_TRUNC_EXPR);
  }
  
  /* Return true if T is a valid op0 of a CALL_EXPR.  */
Index: cp/typeck.c
===================================================================
*** cp/typeck.c	(revision 118652)
--- cp/typeck.c	(working copy)
*************** build_unary_op (enum tree_code code, tre
*** 4146,4154 ****
  	  case CONVERT_EXPR:
  	  case FLOAT_EXPR:
  	  case FIX_TRUNC_EXPR:
- 	  case FIX_FLOOR_EXPR:
- 	  case FIX_ROUND_EXPR:
- 	  case FIX_CEIL_EXPR:
  	    {
  	      tree incremented, modify, value, compound;
  	      if (! lvalue_p (arg) && pedantic)
--- 4146,4151 ----
*************** build_unary_op (enum tree_code code, tre
*** 4301,4309 ****
  	case CONVERT_EXPR:
  	case FLOAT_EXPR:
  	case FIX_TRUNC_EXPR:
- 	case FIX_FLOOR_EXPR:
- 	case FIX_ROUND_EXPR:
- 	case FIX_CEIL_EXPR:
  	  if (! lvalue_p (arg) && pedantic)
  	    pedwarn ("ISO C++ forbids taking the address of a cast to a non-lvalue expression");
  	  break;
--- 4298,4303 ----
Index: dwarf2out.c
===================================================================
*** dwarf2out.c	(revision 118652)
--- dwarf2out.c	(working copy)
*************** loc_descriptor_from_tree_1 (tree loc, in
*** 9478,9486 ****
        break;
  
      case FIX_TRUNC_EXPR:
-     case FIX_CEIL_EXPR:
-     case FIX_FLOOR_EXPR:
-     case FIX_ROUND_EXPR:
        return 0;
  
      default:
--- 9478,9483 ----
Index: expr.c
===================================================================
*** expr.c	(revision 118652)
--- expr.c	(working copy)
*************** expand_expr_real_1 (tree exp, rtx target
*** 8188,8198 ****
  		       subtarget, &op0, &op1, 0);
        return expand_divmod (1, code, mode, op0, op1, target, unsignedp);
  
-     case FIX_ROUND_EXPR:
-     case FIX_FLOOR_EXPR:
-     case FIX_CEIL_EXPR:
-       gcc_unreachable ();			/* Not used for C.  */
- 
      case FIX_TRUNC_EXPR:
        op0 = expand_normal (TREE_OPERAND (exp, 0));
        if (target == 0 || modifier == EXPAND_STACK_PARM)
--- 8188,8193 ----
Index: ada/trans.c
===================================================================
*** ada/trans.c	(revision 118652)
--- ada/trans.c	(working copy)
*************** maybe_stabilize_reference (tree ref, boo
*** 6033,6041 ****
      case CONVERT_EXPR:
      case FLOAT_EXPR:
      case FIX_TRUNC_EXPR:
-     case FIX_FLOOR_EXPR:
-     case FIX_ROUND_EXPR:
-     case FIX_CEIL_EXPR:
      case VIEW_CONVERT_EXPR:
        result
  	= build1 (code, type,
--- 6033,6038 ----
Index: tree-eh.c
===================================================================
*** tree-eh.c	(revision 118652)
--- tree-eh.c	(working copy)
*************** tree_could_trap_p (tree expr)
*** 1956,1964 ****
  
      case CONVERT_EXPR:
      case FIX_TRUNC_EXPR:
-     case FIX_CEIL_EXPR:
-     case FIX_FLOOR_EXPR:
-     case FIX_ROUND_EXPR:
        /* Conversion of floating point might trap.  */
        return honor_nans;
  
--- 1956,1961 ----
Index: fortran/trans-intrinsic.c
===================================================================
*** fortran/trans-intrinsic.c	(revision 118652)
--- fortran/trans-intrinsic.c	(working copy)
*************** typedef struct
*** 160,165 ****
--- 160,166 ----
  }
  real_compnt_info;
  
+ enum rounding_mode { RND_ROUND, RND_TRUNC, RND_CEIL, RND_FLOOR };
  
  /* Evaluate the arguments to an intrinsic function.  */
  
*************** build_round_expr (stmtblock_t * pblock, 
*** 307,329 ****
  
  static tree
  build_fix_expr (stmtblock_t * pblock, tree arg, tree type,
!                enum tree_code op)
  {
    switch (op)
      {
!     case FIX_FLOOR_EXPR:
        return build_fixbound_expr (pblock, arg, type, 0);
        break;
  
!     case FIX_CEIL_EXPR:
        return build_fixbound_expr (pblock, arg, type, 1);
        break;
  
!     case FIX_ROUND_EXPR:
        return build_round_expr (pblock, arg, type);
  
      default:
!       return build1 (op, type, arg);
      }
  }
  
--- 308,331 ----
  
  static tree
  build_fix_expr (stmtblock_t * pblock, tree arg, tree type,
!                enum rounding_mode op)
  {
    switch (op)
      {
!     case RND_FLOOR:
        return build_fixbound_expr (pblock, arg, type, 0);
        break;
  
!     case RND_CEIL:
        return build_fixbound_expr (pblock, arg, type, 1);
        break;
  
!     case RND_ROUND:
        return build_round_expr (pblock, arg, type);
  
      default:
!       gcc_assert (op == RND_TRUNC);
!       return build1 (FIX_TRUNC_EXPR, type, arg);
      }
  }
  
*************** build_fix_expr (stmtblock_t * pblock, tr
*** 338,344 ****
     */
  
  static void
! gfc_conv_intrinsic_aint (gfc_se * se, gfc_expr * expr, enum tree_code op)
  {
    tree type;
    tree itype;
--- 340,346 ----
     */
  
  static void
! gfc_conv_intrinsic_aint (gfc_se * se, gfc_expr * expr, enum rounding_mode op)
  {
    tree type;
    tree itype;
*************** gfc_conv_intrinsic_aint (gfc_se * se, gf
*** 355,361 ****
    /* We have builtin functions for some cases.  */
    switch (op)
      {
!     case FIX_ROUND_EXPR:
        switch (kind)
  	{
  	case 4:
--- 357,363 ----
    /* We have builtin functions for some cases.  */
    switch (op)
      {
!     case RND_ROUND:
        switch (kind)
  	{
  	case 4:
*************** gfc_conv_intrinsic_aint (gfc_se * se, gf
*** 373,379 ****
  	}
        break;
  
!     case FIX_TRUNC_EXPR:
        switch (kind)
  	{
  	case 4:
--- 375,381 ----
  	}
        break;
  
!     case RND_TRUNC:
        switch (kind)
  	{
  	case 4:
*************** gfc_conv_intrinsic_aint (gfc_se * se, gf
*** 437,443 ****
  /* Convert to an integer using the specified rounding mode.  */
  
  static void
! gfc_conv_intrinsic_int (gfc_se * se, gfc_expr * expr, int op)
  {
    tree type;
    tree arg;
--- 439,445 ----
  /* Convert to an integer using the specified rounding mode.  */
  
  static void
! gfc_conv_intrinsic_int (gfc_se * se, gfc_expr * expr, enum rounding_mode op)
  {
    tree type;
    tree arg;
*************** gfc_conv_intrinsic_mod (gfc_se * se, gfc
*** 1076,1084 ****
  
        itype = gfc_get_int_type (ikind);
        if (modulo)
!        tmp = build_fix_expr (&se->pre, tmp, itype, FIX_FLOOR_EXPR);
        else
!        tmp = build_fix_expr (&se->pre, tmp, itype, FIX_TRUNC_EXPR);
        tmp = convert (type, tmp);
        tmp = build3 (COND_EXPR, type, test2, tmp, arg);
        tmp = build2 (MULT_EXPR, type, tmp, arg2);
--- 1078,1086 ----
  
        itype = gfc_get_int_type (ikind);
        if (modulo)
!        tmp = build_fix_expr (&se->pre, tmp, itype, RND_FLOOR);
        else
!        tmp = build_fix_expr (&se->pre, tmp, itype, RND_TRUNC);
        tmp = convert (type, tmp);
        tmp = build3 (COND_EXPR, type, test2, tmp, arg);
        tmp = build2 (MULT_EXPR, type, tmp, arg2);
*************** gfc_conv_intrinsic_function (gfc_se * se
*** 3474,3480 ****
        break;
  
      case GFC_ISYM_AINT:
!       gfc_conv_intrinsic_aint (se, expr, FIX_TRUNC_EXPR);
        break;
  
      case GFC_ISYM_ALL:
--- 3476,3482 ----
        break;
  
      case GFC_ISYM_AINT:
!       gfc_conv_intrinsic_aint (se, expr, RND_TRUNC);
        break;
  
      case GFC_ISYM_ALL:
*************** gfc_conv_intrinsic_function (gfc_se * se
*** 3482,3488 ****
        break;
  
      case GFC_ISYM_ANINT:
!       gfc_conv_intrinsic_aint (se, expr, FIX_ROUND_EXPR);
        break;
  
      case GFC_ISYM_AND:
--- 3484,3490 ----
        break;
  
      case GFC_ISYM_ANINT:
!       gfc_conv_intrinsic_aint (se, expr, RND_ROUND);
        break;
  
      case GFC_ISYM_AND:
*************** gfc_conv_intrinsic_function (gfc_se * se
*** 3515,3533 ****
      case GFC_ISYM_INT2:
      case GFC_ISYM_INT8:
      case GFC_ISYM_LONG:
!       gfc_conv_intrinsic_int (se, expr, FIX_TRUNC_EXPR);
        break;
  
      case GFC_ISYM_NINT:
!       gfc_conv_intrinsic_int (se, expr, FIX_ROUND_EXPR);
        break;
  
      case GFC_ISYM_CEILING:
!       gfc_conv_intrinsic_int (se, expr, FIX_CEIL_EXPR);
        break;
  
      case GFC_ISYM_FLOOR:
!       gfc_conv_intrinsic_int (se, expr, FIX_FLOOR_EXPR);
        break;
  
      case GFC_ISYM_MOD:
--- 3517,3535 ----
      case GFC_ISYM_INT2:
      case GFC_ISYM_INT8:
      case GFC_ISYM_LONG:
!       gfc_conv_intrinsic_int (se, expr, RND_TRUNC);
        break;
  
      case GFC_ISYM_NINT:
!       gfc_conv_intrinsic_int (se, expr, RND_ROUND);
        break;
  
      case GFC_ISYM_CEILING:
!       gfc_conv_intrinsic_int (se, expr, RND_CEIL);
        break;
  
      case GFC_ISYM_FLOOR:
!       gfc_conv_intrinsic_int (se, expr, RND_FLOOR);
        break;
  
      case GFC_ISYM_MOD:
Index: gimplify.c
===================================================================
*** gimplify.c	(revision 118652)
--- gimplify.c	(working copy)
*************** gimplify_expr (tree *expr_p, tree *pre_p
*** 5489,5497 ****
  	  /* FALLTHRU */
  
  	case FIX_TRUNC_EXPR:
- 	case FIX_CEIL_EXPR:
- 	case FIX_FLOOR_EXPR:
- 	case FIX_ROUND_EXPR:
  	  /* unary_expr: ... | '(' cast ')' val | ...  */
  	  ret = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, post_p,
  			       is_gimple_val, fb_rvalue);
--- 5489,5494 ----
Index: tree.def
===================================================================
*** tree.def	(revision 118652)
--- tree.def	(working copy)
*************** DEFTREECODE (RDIV_EXPR, "rdiv_expr", tcc
*** 634,648 ****
     Used for pointer subtraction in C.  */
  DEFTREECODE (EXACT_DIV_EXPR, "exact_div_expr", tcc_binary, 2)
  
! /* Conversion of real to fixed point: four ways to round,
!    like the four ways to divide.
!    CONVERT_EXPR can also be used to convert a real to an integer,
!    and that is what is used in languages that do not have ways of
!    specifying which of these is wanted.  Maybe these are not needed.  */
  DEFTREECODE (FIX_TRUNC_EXPR, "fix_trunc_expr", tcc_unary, 1)
- DEFTREECODE (FIX_CEIL_EXPR, "fix_ceil_expr", tcc_unary, 1)
- DEFTREECODE (FIX_FLOOR_EXPR, "fix_floor_expr", tcc_unary, 1)
- DEFTREECODE (FIX_ROUND_EXPR, "fix_round_expr", tcc_unary, 1)
  
  /* Conversion of an integer to a real.  */
  DEFTREECODE (FLOAT_EXPR, "float_expr", tcc_unary, 1)
--- 634,641 ----
     Used for pointer subtraction in C.  */
  DEFTREECODE (EXACT_DIV_EXPR, "exact_div_expr", tcc_binary, 2)
  
! /* Conversion of real to fixed point by truncation.  */
  DEFTREECODE (FIX_TRUNC_EXPR, "fix_trunc_expr", tcc_unary, 1)
  
  /* Conversion of an integer to a real.  */
  DEFTREECODE (FLOAT_EXPR, "float_expr", tcc_unary, 1)
Index: tree-inline.c
===================================================================
*** tree-inline.c	(revision 118652)
--- tree-inline.c	(working copy)
*************** estimate_num_insns_1 (tree *tp, int *wal
*** 1700,1708 ****
      case MULT_EXPR:
  
      case FIX_TRUNC_EXPR:
-     case FIX_CEIL_EXPR:
-     case FIX_FLOOR_EXPR:
-     case FIX_ROUND_EXPR:
  
      case NEGATE_EXPR:
      case FLOAT_EXPR:
--- 1700,1705 ----
Index: tree-cfg.c
===================================================================
*** tree-cfg.c	(revision 118652)
--- tree-cfg.c	(working copy)
*************** verify_expr (tree *tp, int *walk_subtree
*** 3329,3337 ****
      case NOP_EXPR:
      case CONVERT_EXPR:
      case FIX_TRUNC_EXPR:
-     case FIX_CEIL_EXPR:
-     case FIX_FLOOR_EXPR:
-     case FIX_ROUND_EXPR:
      case FLOAT_EXPR:
      case NEGATE_EXPR:
      case ABS_EXPR:
--- 3329,3334 ----


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