output vector initializers with output_constant_def
Aldy Hernandez
aldyh@redhat.com
Wed May 15 19:07:00 GMT 2002
howdy.
now that i've fixed the reload bug triggered by the vector initializer
code, my previous patch still stands. :)
right now, we are emitting vectors that are mostly zero by
clearing the vector area, and then poking the individual non-zero
items. this generates very inefficient code. for example, for
{0,0,0,69} we would do the following:
clear V0
mem <-- V0
GPRs <-- mem (load multiple)
GPR <-- 69
mem <-- GPRs (store multiple)
V0 <-- mem
in these cases, we should be generating the entire vector with
output_constant_def() and then loading the entire constant ala:
LC0:
.long 0
.long 0
.long 0
.long 69
...
V0 <-- mem(LC0)
({0,0,0,0} will still be generated with one vector clear instruction
though).
and yes, this should all get better when we implement VECTOR_CSTs
for vector initializers.
ok for mainline?
2002-05-13 Aldy Hernandez <aldyh@redhat.com>
* expr.c (expand_expr): Output partially zeroed out vectors with
output_constant_def.
Index: expr.c
===================================================================
RCS file: /cvs/uberbaum/gcc/expr.c,v
retrieving revision 1.454
diff -c -p -r1.454 expr.c
*** expr.c 13 May 2002 04:50:10 -0000 1.454
--- expr.c 16 May 2002 00:34:50 -0000
*************** expand_expr (exp, target, tmode, modifie
*** 6747,6753 ****
fold. Likewise, if we have a target we can use, it is best to
store directly into the target unless the type is large enough
that memcpy will be used. If we are making an initializer and
! all operands are constant, put it in memory as well. */
else if ((TREE_STATIC (exp)
&& ((mode == BLKmode
&& ! (target != 0 && safe_from_p (target, exp, 1)))
--- 6747,6759 ----
fold. Likewise, if we have a target we can use, it is best to
store directly into the target unless the type is large enough
that memcpy will be used. If we are making an initializer and
! all operands are constant, put it in memory as well.
!
! FIXME: Avoid trying to fill vector constructors piece-meal.
! Output them with output_constant_def below unless we're sure
! they're zeros. This should go away when vector initializers
! are treated like VECTOR_CST instead of arrays.
! */
else if ((TREE_STATIC (exp)
&& ((mode == BLKmode
&& ! (target != 0 && safe_from_p (target, exp, 1)))
*************** expand_expr (exp, target, tmode, modifie
*** 6756,6762 ****
&& (! MOVE_BY_PIECES_P
(tree_low_cst (TYPE_SIZE_UNIT (type), 1),
TYPE_ALIGN (type)))
! && ! mostly_zeros_p (exp))))
|| (modifier == EXPAND_INITIALIZER && TREE_CONSTANT (exp)))
{
rtx constructor = output_constant_def (exp, 1);
--- 6762,6770 ----
&& (! MOVE_BY_PIECES_P
(tree_low_cst (TYPE_SIZE_UNIT (type), 1),
TYPE_ALIGN (type)))
! && ((TREE_CODE (type) == VECTOR_TYPE
! && !is_zeros_p (exp))
! || ! mostly_zeros_p (exp)))))
|| (modifier == EXPAND_INITIALIZER && TREE_CONSTANT (exp)))
{
rtx constructor = output_constant_def (exp, 1);
More information about the Gcc-patches
mailing list