summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2006-06-20 15:02:05 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2006-06-20 15:02:05 +0000
commit9fd22806c8efa2bfafae3691c43e691b772d9286 (patch)
treec9dae92eb51b59b6f01612dfb8113ea758cf617a /gcc/fold-const.c
parent4eb278908ec332094891617e74647e64ec8cd11b (diff)
downloadgcc-9fd22806c8efa2bfafae3691c43e691b772d9286.tar.gz
* expr.c (expand_expr_real_1) <VECTOR_CST>: For vector constants with
integer modes, attempt to directly construct an integer constant. * fold-const.c (native_encode_vector): Determine the size of each element from the vector type instead of the first vector element. * tree.c (build_constructor_single): Mark a CONSTRUCTOR as constant, if all of its elements/components are constant. (build_constructor_from_list): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114815 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 5a65586794e..b54658ded62 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6934,12 +6934,13 @@ static int
native_encode_vector (tree expr, unsigned char *ptr, int len)
{
int i, size, offset, count;
- tree elem, elements;
+ tree itype, elem, elements;
- size = 0;
offset = 0;
elements = TREE_VECTOR_CST_ELTS (expr);
count = TYPE_VECTOR_SUBPARTS (TREE_TYPE (expr));
+ itype = TREE_TYPE (TREE_TYPE (expr));
+ size = GET_MODE_SIZE (TYPE_MODE (itype));
for (i = 0; i < count; i++)
{
if (elements)
@@ -6952,18 +6953,15 @@ native_encode_vector (tree expr, unsigned char *ptr, int len)
if (elem)
{
- size = native_encode_expr (elem, ptr+offset, len-offset);
- if (size == 0)
+ if (native_encode_expr (elem, ptr+offset, len-offset) != size)
return 0;
}
- else if (size != 0)
+ else
{
if (offset + size > len)
return 0;
memset (ptr+offset, 0, size);
}
- else
- return 0;
offset += size;
}
return offset;