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]

[tree-ssa] estimate_num_insns_1 fix


Hi,
I would bet I've sent this patch already, but apparently I didn't

estimate_num_insns_1 consider STATEMENT_LIST now as non-zero cost instruction
and MODIFY_EXPR of everything greater than word as 10 instructions.  This
confuses inlining decisions considerably.

The patch bellow fixes it and in addition adds sanity checking so we don't
forget to update the function when new nodes are implemented.

Have little effect on Gerald's testcase - about 1% compilation time slowdown,
but also about 3% memory savings.  Interesting. 

Bootstrapped/regtested i686-pc-gnu-linux. OK?
Honza

2003-12-13  Jan Hubicka  <jh@suse.cz>
	* tree-inline.c (estimate_num_insns_1):  Check that all nodes are known;
	add missing nodes; fix computation of MODIFY_EXPR cost.
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.26.2.67
diff -c -3 -p -r1.26.2.67 tree-inline.c
*** tree-inline.c	25 Nov 2003 14:18:43 -0000	1.26.2.67
--- tree-inline.c	13 Dec 2003 20:53:04 -0000
*************** estimate_num_insns_1 (tree *tp, int *wal
*** 1168,1173 ****
--- 1206,1214 ----
      case SSA_NAME:
      case CATCH_EXPR:
      case EH_FILTER_EXPR:
+     case STATEMENT_LIST:
+     case ERROR_MARK:
+     case NON_LVALUE_EXPR:
        break;
      /* We don't account constants for now.  Assume that the cost is amortized
         by operations that do use them.  We may re-consider this decision once
*************** estimate_num_insns_1 (tree *tp, int *wal
*** 1196,1202 ****
      case PHI_NODE:
        *walk_subtrees = 0;
        return NULL;
-       break;
      /* Reconginze assignments of large structures and constructors of
         big arrays.  */
      case INIT_EXPR:
--- 1237,1242 ----
*************** estimate_num_insns_1 (tree *tp, int *wal
*** 1204,1216 ****
      case MODIFY_EXPR:
      case CONSTRUCTOR:
        {
! 	int size = int_size_in_bytes (TREE_TYPE (x));
  
! 	if (!size || size > MOVE_MAX_PIECES)
  	  *count += 10;
  	else
! 	  *count += 2 * (size + MOVE_MAX - 1) / MOVE_MAX;
! 	return NULL;
        }
        break;
  
--- 1244,1260 ----
      case MODIFY_EXPR:
      case CONSTRUCTOR:
        {
! 	HOST_WIDE_INT size;
! 
! 	if (TREE_TYPE (x) == VOIDmode)
! 	  abort ();
! 
! 	size = int_size_in_bytes (TREE_TYPE (x));
  
! 	if (size < 0 || size > MOVE_MAX_PIECES * MOVE_RATIO)
  	  *count += 10;
  	else
! 	  *count += ((size + MOVE_MAX_PIECES - 1) / MOVE_MAX_PIECES);
        }
        break;
  
*************** estimate_num_insns_1 (tree *tp, int *wal
*** 1298,1304 ****
        *count += 10;
        break;
      default:
!       break;
      }
    return NULL;
  }
--- 1342,1349 ----
        *count += 10;
        break;
      default:
!       /* Abort here se we know we don't miss any nodes.  */
!       abort ();
      }
    return NULL;
  }


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