diff options
author | glisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-10 11:15:14 +0000 |
---|---|---|
committer | glisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-10 11:15:14 +0000 |
commit | 432dd330807c633428562eb7d66ede067fd87262 (patch) | |
tree | 28b2392d93f8ced83cd8e4d51d5232f6883088da /gcc/tree.c | |
parent | 287e36142a3337a665099426864c94af017a535a (diff) | |
download | gcc-432dd330807c633428562eb7d66ede067fd87262.tar.gz |
2013-05-10 Marc Glisse <marc.glisse@inria.fr>
gcc/
* stor-layout.c (element_precision): New function.
* machmode.h (element_precision): Declare it.
* tree.c (build_minus_one_cst): New function.
(element_precision): Likewise.
* tree.h (build_minus_one_cst): Declare new function.
(element_precision): Likewise.
* fold-const.c (operand_equal_p): Use element_precision.
(fold_binary_loc): Handle vector types.
* convert.c (convert_to_integer): Use element_precision.
* gimple.c (iterative_hash_canonical_type): Handle complex and vectors
separately.
gcc/c-family/
* c-common.c (vector_types_convertible_p): No TYPE_PRECISION for
vectors.
gcc/testsuite/
* gcc.dg/vector-shift.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198772 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c index 55fa99bd091..d93c6aeb75a 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1643,6 +1643,45 @@ build_one_cst (tree type) } } +/* Return a constant of arithmetic type TYPE which is the + opposite of the multiplicative identity of the set TYPE. */ + +tree +build_minus_one_cst (tree type) +{ + switch (TREE_CODE (type)) + { + case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: + case POINTER_TYPE: case REFERENCE_TYPE: + case OFFSET_TYPE: + return build_int_cst (type, -1); + + case REAL_TYPE: + return build_real (type, dconstm1); + + case FIXED_POINT_TYPE: + /* We can only generate 1 for accum types. */ + gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type))); + return build_fixed (type, fixed_from_double_int (double_int_minus_one, + TYPE_MODE (type))); + + case VECTOR_TYPE: + { + tree scalar = build_minus_one_cst (TREE_TYPE (type)); + + return build_vector_from_val (type, scalar); + } + + case COMPLEX_TYPE: + return build_complex (type, + build_minus_one_cst (TREE_TYPE (type)), + build_zero_cst (TREE_TYPE (type))); + + default: + gcc_unreachable (); + } +} + /* Build 0 constant of type TYPE. This is used by constructor folding and thus the constant should be represented in memory by zero(es). */ @@ -6949,6 +6988,19 @@ valid_constant_size_p (const_tree size) return true; } +/* Return the precision of the type, or for a complex or vector type the + precision of the type of its elements. */ + +unsigned int +element_precision (const_tree type) +{ + enum tree_code code = TREE_CODE (type); + if (code == COMPLEX_TYPE || code == VECTOR_TYPE) + type = TREE_TYPE (type); + + return TYPE_PRECISION (type); +} + /* Return true if CODE represents an associative tree code. Otherwise return false. */ bool |