This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix inlining size estimates
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org, ak at suse dot de
- Date: Wed, 14 Jan 2004 00:03:22 +0100
- Subject: Fix inlining size estimates
Hi,
this patch backported from SSA branch fix 90% of the remaining inlininig
failures in Linux kernel remained after the builtin_constant_p changes I
sent earlier (I now get 50 failures that are not related to bodies
missing). I've bootstrapped/regtested this on i686-pc-gnu-linux and wil
commit it as obvious.
The bug it fix is wrong estimation of cost of move statements. We are trying
to decide whether assignment = of large type will be expanded as many
assignments or memcpy call and mess this up considering even small assignments
on longs/long longs to be cost of 10 instructions.
Honza
2004-01-13 Jan Hubicka <jh@suse.cz>
* c-common.c (c_estimate_num_insns_1): Fix bug in MODIFY_EXPR
cost estimation.
* expr.c (MOVE_RATIO, CLEAR_RATIO): Move to ...
* expr.h (MOVE_RATIO, CLEAR_RATIO): ... here.
* lang.c (java_estimate_num_insns_1): Fix bug in MODIFY_EXPR cost
estimation.
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.474
diff -c -3 -p -r1.474 c-common.c
*** c-common.c 9 Jan 2004 19:54:52 -0000 1.474
--- c-common.c 13 Jan 2004 20:28:53 -0000
*************** c_estimate_num_insns_1 (tree *tp, int *w
*** 5764,5776 ****
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;
/* Few special cases of expensive operations. This is usefull
--- 5764,5777 ----
case MODIFY_EXPR:
case CONSTRUCTOR:
{
! HOST_WIDE_INT size;
! 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;
/* Few special cases of expensive operations. This is usefull
Index: expr.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.h,v
retrieving revision 1.151
diff -c -3 -p -r1.151 expr.h
*** expr.h 9 Jan 2004 19:54:58 -0000 1.151
--- expr.h 13 Jan 2004 20:28:56 -0000
*************** enum expand_modifier {EXPAND_NORMAL = 0,
*** 66,71 ****
--- 66,95 ----
more information. */
#define OK_DEFER_POP (inhibit_defer_pop -= 1)
+ /* If a memory-to-memory move would take MOVE_RATIO or more simple
+ move-instruction sequences, we will do a movstr or libcall instead. */
+
+ #ifndef MOVE_RATIO
+ #if defined (HAVE_movstrqi) || defined (HAVE_movstrhi) || defined (HAVE_movstrsi) || defined (HAVE_movstrdi) || defined (HAVE_movstrti)
+ #define MOVE_RATIO 2
+ #else
+ /* If we are optimizing for space (-Os), cut down the default move ratio. */
+ #define MOVE_RATIO (optimize_size ? 3 : 15)
+ #endif
+ #endif
+
+ /* If a clear memory operation would take CLEAR_RATIO or more simple
+ move-instruction sequences, we will do a clrstr or libcall instead. */
+
+ #ifndef CLEAR_RATIO
+ #if defined (HAVE_clrstrqi) || defined (HAVE_clrstrhi) || defined (HAVE_clrstrsi) || defined (HAVE_clrstrdi) || defined (HAVE_clrstrti)
+ #define CLEAR_RATIO 2
+ #else
+ /* If we are optimizing for space, cut down the default clear ratio. */
+ #define CLEAR_RATIO (optimize_size ? 3 : 15)
+ #endif
+ #endif
+
enum direction {none, upward, downward};
/* Structure to record the size of a sequence of arguments
Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.148
diff -c -3 -p -r1.148 lang.c
*** java/lang.c 9 Jan 2004 17:08:44 -0000 1.148
--- java/lang.c 13 Jan 2004 20:28:59 -0000
*************** java_estimate_num_insns_1 (tree *tp, int
*** 1134,1146 ****
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;
/* Few special cases of expensive operations. This is usefull
--- 1134,1147 ----
case MODIFY_EXPR:
case CONSTRUCTOR:
{
! HOST_WIDE_INT size;
! 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;
/* Few special cases of expensive operations. This is usefull
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.614
diff -c -3 -p -r1.614 expr.c
*** expr.c 10 Jan 2004 20:50:53 -0000 1.614
--- expr.c 13 Jan 2004 20:30:23 -0000
*************** static char direct_store[NUM_MACHINE_MOD
*** 185,219 ****
static bool float_extend_from_mem[NUM_MACHINE_MODES][NUM_MACHINE_MODES];
- /* If a memory-to-memory move would take MOVE_RATIO or more simple
- move-instruction sequences, we will do a movstr or libcall instead. */
-
- #ifndef MOVE_RATIO
- #if defined (HAVE_movstrqi) || defined (HAVE_movstrhi) || defined (HAVE_movstrsi) || defined (HAVE_movstrdi) || defined (HAVE_movstrti)
- #define MOVE_RATIO 2
- #else
- /* If we are optimizing for space (-Os), cut down the default move ratio. */
- #define MOVE_RATIO (optimize_size ? 3 : 15)
- #endif
- #endif
-
/* This macro is used to determine whether move_by_pieces should be called
to perform a structure copy. */
#ifndef MOVE_BY_PIECES_P
#define MOVE_BY_PIECES_P(SIZE, ALIGN) \
(move_by_pieces_ninsns (SIZE, ALIGN) < (unsigned int) MOVE_RATIO)
- #endif
-
- /* If a clear memory operation would take CLEAR_RATIO or more simple
- move-instruction sequences, we will do a clrstr or libcall instead. */
-
- #ifndef CLEAR_RATIO
- #if defined (HAVE_clrstrqi) || defined (HAVE_clrstrhi) || defined (HAVE_clrstrsi) || defined (HAVE_clrstrdi) || defined (HAVE_clrstrti)
- #define CLEAR_RATIO 2
- #else
- /* If we are optimizing for space, cut down the default clear ratio. */
- #define CLEAR_RATIO (optimize_size ? 3 : 15)
- #endif
#endif
/* This macro is used to determine whether clear_by_pieces should be
--- 185,195 ----