diff options
Diffstat (limited to 'gcc/tree-ssa.c')
-rw-r--r-- | gcc/tree-ssa.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index edbae39..10ec35b 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -961,12 +961,9 @@ useless_type_conversion_p_1 (tree outer_type, tree inner_type) && TYPE_VOLATILE (TREE_TYPE (outer_type))) return false; - /* Do not lose casts between pointers with different - TYPE_REF_CAN_ALIAS_ALL setting or alias sets. */ - if ((TYPE_REF_CAN_ALIAS_ALL (inner_type) - != TYPE_REF_CAN_ALIAS_ALL (outer_type)) - || (get_alias_set (TREE_TYPE (inner_type)) - != get_alias_set (TREE_TYPE (outer_type)))) + /* Do not lose casts between pointers that when dereferenced access + memory with different alias sets. */ + if (get_deref_alias_set (inner_type) != get_deref_alias_set (outer_type)) return false; /* We do not care for const qualification of the pointed-to types @@ -1002,6 +999,13 @@ useless_type_conversion_p_1 (tree outer_type, tree inner_type) if (TREE_CODE (inner_type) != TREE_CODE (outer_type)) return false; + /* Conversions from array types with unknown extent to + array types with known extent are not useless. */ + if (TREE_CODE (inner_type) == ARRAY_TYPE + && !TYPE_DOMAIN (inner_type) + && TYPE_DOMAIN (outer_type)) + return false; + /* ??? This seems to be necessary even for aggregates that don't have TYPE_STRUCTURAL_EQUALITY_P set. */ |