aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2006-06-20 15:02:05 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2006-06-20 15:02:05 +0000
commit1000b34d95a6319206389feb136879d42d4675f2 (patch)
treec9dae92eb51b59b6f01612dfb8113ea758cf617a /gcc/fold-const.c
parentc82f61c591c903d2faab8e9e0257c2fbb004c1fc (diff)
downloadgcc-1000b34d95a6319206389feb136879d42d4675f2.zip
gcc-1000b34d95a6319206389feb136879d42d4675f2.tar.gz
gcc-1000b34d95a6319206389feb136879d42d4675f2.tar.bz2
expr.c (expand_expr_real_1): For vector constants with integer modes...
* 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. From-SVN: r114815
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 5a65586..b54658d 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;