Patch to improve store_expr
Jan Hubicka
hubicka@atrey.karlin.mff.cuni.cz
Wed Apr 26 07:03:00 GMT 2000
Hi
The store_expr contains direct memset/bzero call. I don't see purpose
why not use clear_storage infrastructure here. The patch avoids memset
in following testcase created by Jakub:
struct c { char name[20]; };
void bar(struct c *);
void foo(void)
{
struct c a = {"string"};
bar(&a);
}
Wed Apr 26 16:00:25 MET DST 2000 Jan Hubicka <jh@suse.cz>
* expr.c (store_expr): Use clear_storage instead of direct memset
libcall.
Index: egcs/gcc//expr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/expr.c,v
retrieving revision 1.231
diff -c -3 -p -r1.231 expr.c
*** expr.c 2000/04/22 10:36:44 1.231
--- expr.c 2000/04/26 13:55:30
*************** store_expr (exp, target, want_value)
*** 3933,3938 ****
--- 3933,3939 ----
= size_binop (MIN_EXPR,
make_tree (sizetype, size),
size_int (TREE_STRING_LENGTH (exp)));
+ int align = TYPE_ALIGN (TREE_TYPE (exp));
rtx copy_size_rtx = expand_expr (copy_size, NULL_RTX,
VOIDmode, 0);
rtx label = 0;
*************** store_expr (exp, target, want_value)
*** 3951,3956 ****
--- 3952,3960 ----
{
addr = plus_constant (addr, TREE_STRING_LENGTH (exp));
size = plus_constant (size, - TREE_STRING_LENGTH (exp));
+ align = MIN (align, (BITS_PER_UNIT
+ * (INTVAL (copy_size_rtx)
+ & - INTVAL (copy_size_rtx))));
}
else
{
*************** store_expr (exp, target, want_value)
*** 3963,3972 ****
--- 3967,3978 ----
copy_size_rtx, NULL_RTX, 0,
OPTAB_LIB_WIDEN);
+ align = BITS_PER_UNIT;
label = gen_label_rtx ();
emit_cmp_and_jump_insns (size, const0_rtx, LT, NULL_RTX,
GET_MODE (size), 0, 0, label);
}
+ align = MIN (align, expr_align (copy_size));
if (size != const0_rtx)
{
*************** store_expr (exp, target, want_value)
*** 3977,3998 ****
size, TYPE_MODE (sizetype),
GEN_INT (MEMORY_USE_WO),
TYPE_MODE (integer_type_node));
! #ifdef TARGET_MEM_FUNCTIONS
! emit_library_call (memset_libfunc, 0, VOIDmode, 3,
! addr, ptr_mode,
! const0_rtx, TYPE_MODE (integer_type_node),
! convert_to_mode (TYPE_MODE (sizetype),
! size,
! TREE_UNSIGNED (sizetype)),
! TYPE_MODE (sizetype));
! #else
! emit_library_call (bzero_libfunc, 0, VOIDmode, 2,
! addr, ptr_mode,
! convert_to_mode (TYPE_MODE (integer_type_node),
! size,
! TREE_UNSIGNED (integer_type_node)),
! TYPE_MODE (integer_type_node));
! #endif
}
if (label)
--- 3983,3989 ----
size, TYPE_MODE (sizetype),
GEN_INT (MEMORY_USE_WO),
TYPE_MODE (integer_type_node));
! clear_storage (gen_rtx_MEM (BLKmode, addr), size, align);
}
if (label)
More information about the Gcc-patches
mailing list