diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2016-05-20 21:46:58 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2016-05-20 21:46:58 +0000 |
commit | 55c8849f5d8ca231dba2e4ed2c40c4d435c84ae3 (patch) | |
tree | 0b4f1df898e1cc3a5d61e29748c1888ebaa51560 /gcc/ada | |
parent | aa6d7407f90130dfea5df768787ce5c46c87f07b (diff) | |
download | gcc-55c8849f5d8ca231dba2e4ed2c40c4d435c84ae3.zip gcc-55c8849f5d8ca231dba2e4ed2c40c4d435c84ae3.tar.gz gcc-55c8849f5d8ca231dba2e4ed2c40c4d435c84ae3.tar.bz2 |
tree-vrp.c (compare_values_warnv): Simplify handling of symbolic ranges by calling get_single_symbol and tidy up.
* tree-vrp.c (compare_values_warnv): Simplify handling of symbolic
ranges by calling get_single_symbol and tidy up. Look more closely
into NAME + CST1 vs CST2 comparisons if type overflow is undefined.
ada/
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Signed_Integer_Subtype>:
Make same-sized subtypes of signed base types signed.
* gcc-interface/utils.c (make_type_from_size): Adjust to above change.
(unchecked_convert): Likewise.
From-SVN: r236548
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 10 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/utils.c | 18 |
3 files changed, 30 insertions, 5 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 49c463a..525b89f 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2016-05-20 Eric Botcazou <ebotcazou@adacore.com> + + * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Signed_Integer_Subtype>: + Make same-sized subtypes of signed base types signed. + * gcc-interface/utils.c (make_type_from_size): Adjust to above change. + (unchecked_convert): Likewise. + 2016-05-16 Eric Botcazou <ebotcazou@adacore.com> * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Do not build diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index b51200f..6b6bc07 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -1814,7 +1814,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) /* First subtypes of Character are treated as Character; otherwise this should be an unsigned type if the base type is unsigned or if the lower bound is constant and non-negative or if the type - is biased. */ + is biased. However, even if the lower bound is constant and + non-negative, we use a signed type for a subtype with the same + size as its signed base type, because this eliminates useless + conversions to it and gives more leeway to the optimizer; but + this means that we will need to explicitly test for this case + when we change the representation based on the RM size. */ if (kind == E_Enumeration_Subtype && No (First_Literal (Etype (gnat_entity))) && Esize (gnat_entity) == RM_Size (gnat_entity) @@ -1822,7 +1827,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) && flag_signed_char) gnu_type = make_signed_type (CHAR_TYPE_SIZE); else if (Is_Unsigned_Type (Etype (gnat_entity)) - || Is_Unsigned_Type (gnat_entity) + || (Esize (Etype (gnat_entity)) != Esize (gnat_entity) + && Is_Unsigned_Type (gnat_entity)) || Has_Biased_Representation (gnat_entity)) gnu_type = make_unsigned_type (esize); else diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 7494065..798048a 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -1116,7 +1116,14 @@ make_type_from_size (tree type, tree size_tree, bool for_biased) break; biased_p |= for_biased; - if (TYPE_UNSIGNED (type) || biased_p) + + /* The type should be an unsigned type if the original type is unsigned + or if the lower bound is constant and non-negative or if the type is + biased, see E_Signed_Integer_Subtype case of gnat_to_gnu_entity. */ + if (TYPE_UNSIGNED (type) + || (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST + && tree_int_cst_sgn (TYPE_MIN_VALUE (type)) >= 0) + || biased_p) new_type = make_unsigned_type (size); else new_type = make_signed_type (size); @@ -5111,7 +5118,9 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) /* If the result is an integral type whose precision is not equal to its size, sign- or zero-extend the result. We need not do this if the input is an integral type of the same precision and signedness or if the output - is a biased type or if both the input and output are unsigned. */ + is a biased type or if both the input and output are unsigned, or if the + lower bound is constant and non-negative, see E_Signed_Integer_Subtype + case of gnat_to_gnu_entity. */ if (!notrunc_p && INTEGRAL_TYPE_P (type) && TYPE_RM_SIZE (type) @@ -5123,7 +5132,10 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) ? TYPE_RM_SIZE (etype) : TYPE_SIZE (etype)) == 0) && !(code == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (type)) - && !(TYPE_UNSIGNED (type) && TYPE_UNSIGNED (etype))) + && !((TYPE_UNSIGNED (type) + || (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST + && tree_int_cst_sgn (TYPE_MIN_VALUE (type)) >= 0)) + && TYPE_UNSIGNED (etype))) { tree base_type = gnat_type_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)), |