diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2013-05-10 13:15:14 +0200 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2013-05-10 11:15:14 +0000 |
commit | a5e0cd1d9bd6fbcff37a6545d8e60b36ff6ea7a7 (patch) | |
tree | 28b2392d93f8ced83cd8e4d51d5232f6883088da /gcc/tree.c | |
parent | cb2558bc95658155c76e1468ed4db64359452dc2 (diff) | |
download | gcc-a5e0cd1d9bd6fbcff37a6545d8e60b36ff6ea7a7.zip gcc-a5e0cd1d9bd6fbcff37a6545d8e60b36ff6ea7a7.tar.gz gcc-a5e0cd1d9bd6fbcff37a6545d8e60b36ff6ea7a7.tar.bz2 |
stor-layout.c (element_precision): New function.
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.
From-SVN: r198772
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 52 |
1 files changed, 52 insertions, 0 deletions
@@ -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 |